Next / Previous / Contents / Shipman's homepage

3. Top-level modules

Each of these modules is loaded by the emacs user to set up one particular format.

3.1. maps2004m.el: Multiple-station sets, MAPS 2004/2006 protocol

This module sets up a field structure for a multi-station set in the current MAPS protocol.

maps2004m.el
;; maps2004m.el:  Set up field values and keybindings for
;;   MAPS 2004 protocol, multiple stations.
;; To use, run emacs with this command line option:
;;   emacs -l maps2004m filename
;;

First we load the common functions used by all the top-level modules.

maps2004m.el
(load "ibp.el")

Next comes the table that defines the field layout of the tail portion in the MAPS 2004 protocol.

maps2004m.el
(setq field-def-list
      (vector
       (field-def-object 4 "????")      ;; Species code
       (field-def-object 3 "0  " )      ;; Age, how-aged
       (field-def-object 3 "u  " )      ;; Sex, how-sexed
       (field-def-object 4 nil )        ;; Skull through fat
       (field-def-object 4 nil )        ;; Four old molt codes
       (field-def-object 4 nil )        ;; Pri.cov/Sec.cov/Pri/Sec
       (field-def-object 4 nil )        ;; Tert/Rect/Body plum/Nonfeath
       (field-def-object 3 nil )        ;; Wing length
       (field-def-object 4 nil )        ;; Weight
       (field-def-object 5 "3????" )    ;; Status, date
       (field-def-object 3 nil )        ;; Time
       (field-def-object 4 nil )        ;; Station code
       (field-def-object 2 nil ) ) )    ;; Net

Finally, we bind keys to the tab and duplicate functions. (Putting these lines in ibp.el doesn't work. Also, the editor needs to be put into fundamental mode with “M-x fundamental-mode” because other modes may not treat tab correctly.)

There is quite a lot of trickery packaged into these two lines. The global-set-key function takes two arguments: the description of a key, and the (quoted) name of the function to be bound to it.

Key descriptions may use either quoted strings or emacs vector objects.

For binding the tab key, we use the quote string C-i.

maps2004m.el
(global-set-key "\C-i" 'ibp-tab)

The name of the ditto key varies across platforms. We'll use vector objects here, which are a list of symbols enclosed in square brackets. Sometimes (as in a separate emacs window in Linux) it is considered C-^, but sometimes (as in an emacs session running in a shell window) it is treated as C-6. We bind both of these so that the module will work in either case.

maps2004m.el
(global-set-key [?\C-^] 'ibp-ditto)
(global-set-key [?\C-6] 'ibp-ditto)