annotate lisp/textmodes/bib-mode.el @ 111012:2b6e7f137773

Fix the MSDOS build broken by last revisions. msdos/sed1v2.inp: Use $(..) instead of ${..} in all edit commands. Needed because of changes in revno 101897. msdos/sed6.inp (mkinfodir): Edit to avoid Unix shell-isms. Needed because of changes in revno 101876. src/unexcoff.c (make_hdr): Fix prototype according to changes in revno 101757.
author Eli Zaretskii <eliz@gnu.org>
date Fri, 15 Oct 2010 20:45:12 +0200
parents 1d1d5d9bd884
children 376148b31b5e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38412
253f761ad37b Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents: 20959
diff changeset
1 ;;; bib-mode.el --- major mode for editing bib files
662
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
2
101101
86ea76dd60c9 Comment (add Author:, based on authors.el).
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
3 ;; Copyright (C) 1989, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 105813
diff changeset
4 ;; 2009, 2010 Free Software Foundation, Inc.
845
213978acbc1e entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 807
diff changeset
5
101101
86ea76dd60c9 Comment (add Author:, based on authors.el).
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
6 ;; Author: Henry Kautz
86ea76dd60c9 Comment (add Author:, based on authors.el).
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
7 ;; (according to authors.el)
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
8 ;; Maintainer: FSF
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
9 ;; Keywords: bib
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 662
diff changeset
10
187
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 ;; This file is part of GNU Emacs.
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12
94670
f4a69fedbd46 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
187
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
94670
f4a69fedbd46 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
15 ;; the Free Software Foundation, either version 3 of the License, or
f4a69fedbd46 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
16 ;; (at your option) any later version.
187
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 ;; GNU General Public License for more details.
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
94670
f4a69fedbd46 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
187
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25
2307
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 845
diff changeset
26 ;;; Commentary:
187
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 ;; GNU Emacs code to help maintain databases compatible with (troff)
49599
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41564
diff changeset
29 ;; refer and lookbib. The file bib-file should be set to your
187
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30 ;; bibliography file. Keys are automagically inserted as you type,
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 ;; and appropriate keys are presented for various kinds of entries.
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32
2307
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 845
diff changeset
33 ;;; Code:
38412
253f761ad37b Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents: 20959
diff changeset
34
20959
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 16285
diff changeset
35 (defgroup bib nil
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 16285
diff changeset
36 "Major mode for editing bib files."
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 16285
diff changeset
37 :prefix "bib-"
52282
96a4d917b189 (bib): Add :group external.
Dave Love <fx@gnu.org>
parents: 49599
diff changeset
38 :group 'external
20959
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 16285
diff changeset
39 :group 'wp)
2307
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 845
diff changeset
40
20959
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 16285
diff changeset
41 (defcustom bib-file "~/my-bibliography.bib"
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 16285
diff changeset
42 "Default name of file used by `addbib'."
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 16285
diff changeset
43 :type 'file
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 16285
diff changeset
44 :group 'bib)
187
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45
20959
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 16285
diff changeset
46 (defcustom unread-bib-file "~/to-be-read.bib"
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 16285
diff changeset
47 "Default name of file used by `unread-bib' in Bib mode."
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 16285
diff changeset
48 :type 'file
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 16285
diff changeset
49 :group 'bib)
187
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 (defvar bib-mode-map (copy-keymap text-mode-map))
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 (define-key bib-mode-map "\C-M" 'return-key-bib)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 (define-key bib-mode-map "\C-c\C-u" 'unread-bib)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 (define-key bib-mode-map "\C-c\C-@" 'mark-bib)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 (define-key bib-mode-map "\e`" 'abbrev-mode)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 (defun addbib ()
49599
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41564
diff changeset
58 "Set up editor to add to troff bibliography file specified
187
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 by global variable `bib-file'. See description of `bib-mode'."
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 (interactive)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 (find-file bib-file)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62 (goto-char (point-max))
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 (bib-mode)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 )
49599
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41564
diff changeset
65
39896
258ac90a4fed Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
66 (define-derived-mode bib-mode text-mode "Bib"
49599
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41564
diff changeset
67 "Mode for editing `lookbib' style bibliographies.
187
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68 Hit RETURN to get next % field key.
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 If you want to ignore this field, just hit RETURN again.
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 Use `text-mode' to turn this feature off.
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 journal papers: A* T D J V N P K W X
49599
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41564
diff changeset
73 articles in books & proceedings: A* T D B E* I C P K W X
187
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74 tech reports: A* T D R I C K W X
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 books: A* T D I C K W X
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77 Fields:
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79 A uthor T itle D ate J ournal
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80 V olume N umber P age K eywords
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 B in book or proceedings E ditor C ity & state
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 I nstitution, school, or publisher
49599
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 41564
diff changeset
83 R eport number or 'phd thesis' or 'masters thesis' or 'draft' or
187
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84 'unnumbered' or 'unpublished'
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 W here can be found locally (login name, or ailib, etc.)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 X comments (not used in indexing)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 \\[unread-bib] appends current entry to a different file (for example,
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 a file of papers to be read in the future), given by the value of the
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 variable `unread-bib-file'.
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91 \\[mark-bib] marks current or previous entry.
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92 Abbreviations are saved in `bib-mode-abbrev-table'.
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93 Hook can be stored in `bib-mode-hook'.
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 Field keys given by variable `bib-assoc'.
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 Commands:
39896
258ac90a4fed Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
97 \\{bib-mode-map}"
258ac90a4fed Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
98 (abbrev-mode 1))
187
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99
39896
258ac90a4fed Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
100 (defconst bib-assoc
258ac90a4fed Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
101 '((" *$" . "%A ")
258ac90a4fed Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
102 ("%A ." . "%A ")
258ac90a4fed Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
103 ("%A $" . "%T ")
258ac90a4fed Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
104 ("%T " . "%D ")
258ac90a4fed Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
105 ("%D " . "%J ")
258ac90a4fed Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
106 ("%J ." . "%V ")
258ac90a4fed Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
107 ("%V " . "%N ")
258ac90a4fed Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
108 ("%N " . "%P ")
258ac90a4fed Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
109 ("%P " . "%K ")
258ac90a4fed Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
110 ("%K " . "%W ")
258ac90a4fed Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
111 ("%W " . "%X ")
258ac90a4fed Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
112 ("%X " . "")
258ac90a4fed Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
113 ("%J $" . "%B ")
258ac90a4fed Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
114 ("%B ." . "%E ")
258ac90a4fed Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
115 ("%E ." . "%E ")
258ac90a4fed Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
116 ("%E $" . "%I ")
258ac90a4fed Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
117 ("%I " . "%C ")
258ac90a4fed Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
118 ("%C " . "%P ")
258ac90a4fed Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
119 ("%B $" . "%R ")
258ac90a4fed Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
120 ("%R " . "%I "))
258ac90a4fed Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
121 "Describes bibliographic database format.
258ac90a4fed Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
122 A line beginning with the car of an entry is followed by one beginning
258ac90a4fed Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38412
diff changeset
123 with the cdr.")
187
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125 (defun bib-find-key (slots)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 (cond
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127 ((null slots)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 (if (bobp)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129 ""
85451
e1af3a725ca4 * textmodes/two-column.el (2C-split, 2C-merge):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78225
diff changeset
130 (progn (forward-line -1) (bib-find-key bib-assoc))))
187
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131 ((looking-at (car (car slots)))
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 (cdr (car slots)))
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 (t (bib-find-key (cdr slots)))
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134 ))
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136
20959
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 16285
diff changeset
137 (defcustom bib-auto-capitalize t
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 16285
diff changeset
138 "*True to automatically capitalize appropriate fields in Bib mode."
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 16285
diff changeset
139 :type 'boolean
9b831f34ff7d Customized.
Stephen Eglen <stephen@gnu.org>
parents: 16285
diff changeset
140 :group 'bib)
187
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
142 (defconst bib-capitalized-fields "%[AETCBIJR]")
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 (defun return-key-bib ()
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 "Magic when user hits return, used by `bib-mode'."
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146 (interactive)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147 (if (eolp)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148 (let (empty new-key beg-current end-current)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149 (beginning-of-line)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150 (setq empty (looking-at "%. $"))
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151 (if (not empty)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152 (progn
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 (end-of-line)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154 (newline)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 (forward-line -1)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 ))
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157 (end-of-line)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 (setq end-current (point))
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159 (beginning-of-line)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160 (setq beg-current (point))
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161 (setq new-key (bib-find-key bib-assoc))
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162 (if (and (not empty) bib-auto-capitalize
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163 (looking-at bib-capitalized-fields))
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 (save-excursion
16285
0aa65f31f7e4 (bib-capitalize-title-stop-words): Renamed from capit...
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
165 (bib-capitalize-title-region (+ (point) 3) end-current)))
187
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 (goto-char beg-current)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167 (if empty
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168 (kill-line nil)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169 (forward-line 1)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170 )
41564
8fab3d5b7fcf (return-key-bib): Use insert instead of insert-string.
Pavel Janík <Pavel@Janik.cz>
parents: 39896
diff changeset
171 (insert new-key))
187
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172 (newline)))
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
173
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
174 (defun mark-bib ()
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175 "Set mark at beginning of current or previous bib entry, point at end."
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
176 (interactive)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
177 (beginning-of-line nil)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
178 (if (looking-at "^ *$") (re-search-backward "[^ \n]" nil 2))
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
179 (re-search-backward "^ *$" nil 2)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180 (re-search-forward "^%")
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181 (beginning-of-line nil)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182 (push-mark (point))
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
183 (re-search-forward "^ *$" nil 2)
85451
e1af3a725ca4 * textmodes/two-column.el (2C-split, 2C-merge):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78225
diff changeset
184 (forward-line 1)
187
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
185 (beginning-of-line nil))
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187 (defun unread-bib ()
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
188 "Append current or previous entry to file of unread papers
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189 named by variable `unread-bib-file'."
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190 (interactive)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191 (mark-bib)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192 (if (get-file-buffer unread-bib-file)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
193 (append-to-buffer (get-file-buffer unread-bib-file) (mark) (point))
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
194 (append-to-file (mark) (point) unread-bib-file)))
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196
16285
0aa65f31f7e4 (bib-capitalize-title-stop-words): Renamed from capit...
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
197 (defvar bib-capitalize-title-stop-words
187
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
198 (concat
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199 "the\\|and\\|of\\|is\\|a\\|an\\|of\\|for\\|in\\|to\\|in\\|on\\|at\\|"
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 "by\\|with\\|that\\|its")
16285
0aa65f31f7e4 (bib-capitalize-title-stop-words): Renamed from capit...
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
201 "Words not to be capitalized in a title (unless the first word).")
187
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202
16285
0aa65f31f7e4 (bib-capitalize-title-stop-words): Renamed from capit...
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
203 (defvar bib-capitalize-title-stop-regexp
0aa65f31f7e4 (bib-capitalize-title-stop-words): Renamed from capit...
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
204 (concat "\\(" bib-capitalize-title-stop-words "\\)\\(\\b\\|'\\)"))
187
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205
16285
0aa65f31f7e4 (bib-capitalize-title-stop-words): Renamed from capit...
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
206 (defun bib-capitalize-title-region (begin end)
187
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207 "Like `capitalize-region', but don't capitalize stop words, except the first."
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208 (interactive "r")
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
209 (let ((case-fold-search nil) (orig-syntax-table (syntax-table)))
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210 (unwind-protect
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211 (save-restriction
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212 (set-syntax-table text-mode-syntax-table)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 (narrow-to-region begin end)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214 (goto-char (point-min))
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 (if (looking-at "[A-Z][a-z]*[A-Z]")
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216 (forward-word 1)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 (capitalize-word 1))
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 (while (re-search-forward "\\<" nil t)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219 (if (looking-at "[A-Z][a-z]*[A-Z]")
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220 (forward-word 1)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221 (if (let ((case-fold-search t))
16285
0aa65f31f7e4 (bib-capitalize-title-stop-words): Renamed from capit...
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
222 (looking-at bib-capitalize-title-stop-regexp))
187
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 (downcase-word 1)
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224 (capitalize-word 1)))
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225 ))
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226 (set-syntax-table orig-syntax-table))))
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228
16285
0aa65f31f7e4 (bib-capitalize-title-stop-words): Renamed from capit...
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
229 (defun bib-capitalize-title (s)
187
cf77dffd7bba Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230 "Like `capitalize', but don't capitalize stop words, except the first."
105813
df4934f25eef * textmodes/two-column.el (2C-split):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101101
diff changeset
231 (with-current-buffer (get-buffer-create "$$$Scratch$$$")
df4934f25eef * textmodes/two-column.el (2C-split):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101101
diff changeset
232 (erase-buffer)
df4934f25eef * textmodes/two-column.el (2C-split):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101101
diff changeset
233 (insert s)
df4934f25eef * textmodes/two-column.el (2C-split):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101101
diff changeset
234 (bib-capitalize-title-region (point-min) (point-max))
df4934f25eef * textmodes/two-column.el (2C-split):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101101
diff changeset
235 (buffer-string)))
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 187
diff changeset
236
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 187
diff changeset
237 (provide 'bib-mode)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 187
diff changeset
238
93975
1e3a407766b9 Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
239 ;; arch-tag: e3a97958-3c2c-487f-9557-fafc3c98452d
662
8a533acedb77 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
240 ;;; bib-mode.el ends here