comparison lisp/textmodes/bib-mode.el @ 39896:258ac90a4fed

Use define-derived-mode.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sat, 13 Oct 2001 19:22:43 +0000
parents 253f761ad37b
children 8fab3d5b7fcf
comparison
equal deleted inserted replaced
39895:9c794d6eeb76 39896:258ac90a4fed
49 (defvar bib-mode-map (copy-keymap text-mode-map)) 49 (defvar bib-mode-map (copy-keymap text-mode-map))
50 (define-key bib-mode-map "\C-M" 'return-key-bib) 50 (define-key bib-mode-map "\C-M" 'return-key-bib)
51 (define-key bib-mode-map "\C-c\C-u" 'unread-bib) 51 (define-key bib-mode-map "\C-c\C-u" 'unread-bib)
52 (define-key bib-mode-map "\C-c\C-@" 'mark-bib) 52 (define-key bib-mode-map "\C-c\C-@" 'mark-bib)
53 (define-key bib-mode-map "\e`" 'abbrev-mode) 53 (define-key bib-mode-map "\e`" 'abbrev-mode)
54 (defvar bib-mode-abbrev-table nil
55 "Abbrev table used in Bib mode")
56 54
57 (defun addbib () 55 (defun addbib ()
58 "Set up editor to add to troff bibliography file specified 56 "Set up editor to add to troff bibliography file specified
59 by global variable `bib-file'. See description of `bib-mode'." 57 by global variable `bib-file'. See description of `bib-mode'."
60 (interactive) 58 (interactive)
61 (find-file bib-file) 59 (find-file bib-file)
62 (goto-char (point-max)) 60 (goto-char (point-max))
63 (bib-mode) 61 (bib-mode)
64 ) 62 )
65 63
66 (defun bib-mode () 64 (define-derived-mode bib-mode text-mode "Bib"
67 "Mode for editing `lookbib' style bibliographies. 65 "Mode for editing `lookbib' style bibliographies.
68 Hit RETURN to get next % field key. 66 Hit RETURN to get next % field key.
69 If you want to ignore this field, just hit RETURN again. 67 If you want to ignore this field, just hit RETURN again.
70 Use `text-mode' to turn this feature off. 68 Use `text-mode' to turn this feature off.
71 69
92 Abbreviations are saved in `bib-mode-abbrev-table'. 90 Abbreviations are saved in `bib-mode-abbrev-table'.
93 Hook can be stored in `bib-mode-hook'. 91 Hook can be stored in `bib-mode-hook'.
94 Field keys given by variable `bib-assoc'. 92 Field keys given by variable `bib-assoc'.
95 93
96 Commands: 94 Commands:
97 \\{bib-mode-map} 95 \\{bib-mode-map}"
98 " 96 (abbrev-mode 1))
99 (interactive) 97
100 (text-mode) 98 (defconst bib-assoc
101 (use-local-map bib-mode-map) 99 '((" *$" . "%A ")
102 (setq mode-name "Bib") 100 ("%A ." . "%A ")
103 (setq major-mode 'bib-mode) 101 ("%A $" . "%T ")
104 (define-abbrev-table 'bib-mode-abbrev-table ()) 102 ("%T " . "%D ")
105 (setq local-abbrev-table bib-mode-abbrev-table) 103 ("%D " . "%J ")
106 (abbrev-mode 1) 104 ("%J ." . "%V ")
107 (run-hooks 'bib-mode-hook) 105 ("%V " . "%N ")
108 ) 106 ("%N " . "%P ")
109 107 ("%P " . "%K ")
110 (defconst bib-assoc '( 108 ("%K " . "%W ")
111 (" *$" . "%A ") 109 ("%W " . "%X ")
112 ("%A ." . "%A ") 110 ("%X " . "")
113 ("%A $" . "%T ") 111 ("%J $" . "%B ")
114 ("%T " . "%D ") 112 ("%B ." . "%E ")
115 ("%D " . "%J ") 113 ("%E ." . "%E ")
116 ("%J ." . "%V ") 114 ("%E $" . "%I ")
117 ("%V " . "%N ") 115 ("%I " . "%C ")
118 ("%N " . "%P ") 116 ("%C " . "%P ")
119 ("%P " . "%K ") 117 ("%B $" . "%R ")
120 ("%K " . "%W ") 118 ("%R " . "%I "))
121 ("%W " . "%X ") 119 "Describes bibliographic database format.
122 ("%X " . "") 120 A line beginning with the car of an entry is followed by one beginning
123 ("%J $" . "%B ") 121 with the cdr.")
124 ("%B ." . "%E ")
125 ("%E ." . "%E ")
126 ("%E $" . "%I ")
127 ("%I " . "%C ")
128 ("%C " . "%P ")
129 ("%B $" . "%R ")
130 ("%R " . "%I ")
131 )
132
133 "Describes bibliographic database format. A line beginning with
134 the car of an entry is followed by one beginning with the cdr.
135 ")
136 122
137 (defun bib-find-key (slots) 123 (defun bib-find-key (slots)
138 (cond 124 (cond
139 ((null slots) 125 ((null slots)
140 (if (bobp) 126 (if (bobp)