Mercurial > emacs
annotate lisp/textmodes/bibtex.el @ 51740:b9b903974028
Don't require `derived' at compile-time.
author | John Paul Wallington <jpw@pobox.com> |
---|---|
date | Sat, 05 Jul 2003 11:20:30 +0000 |
parents | 83476384bebd |
children | f63c242330b2 |
rev | line source |
---|---|
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
1 ;;; bibtex.el --- BibTeX mode for GNU Emacs |
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
2 |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3 ;; Copyright (C) 1992,94,95,96,97,98,1999,2003 Free Software Foundation, Inc. |
845 | 4 |
14789
d68b71228abd
(bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents:
14410
diff
changeset
|
5 ;; Author: Stefan Schoef <schoef@offis.uni-oldenburg.de> |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
6 ;; Bengt Martensson <bengt@mathematik.uni-Bremen.de> |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
7 ;; Mark Shapiro <shapiro@corto.inria.fr> |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
8 ;; Mike Newton <newton@gumby.cs.caltech.edu> |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
9 ;; Aaron Larson <alarson@src.honeywell.com> |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
10 ;; Dirk Herrmann <D.Herrmann@tu-bs.de> |
45849 | 11 ;; Maintainer: Roland Winkler <roland.winkler@physik.uni-erlangen.de> |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
12 ;; Keywords: BibTeX, LaTeX, TeX |
810
80303373daae
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
13 |
257 | 14 ;; This file is part of GNU Emacs. |
15 | |
16 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
17 ;; it under the terms of the GNU General Public License as published by | |
1851 | 18 ;; the Free Software Foundation; either version 2, or (at your option) |
257 | 19 ;; any later version. |
20 | |
21 ;; GNU Emacs is distributed in the hope that it will be useful, | |
22 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
23 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
24 ;; GNU General Public License for more details. | |
25 | |
26 ;; You should have received a copy of the GNU General Public License | |
14169 | 27 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
28 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
29 ;; Boston, MA 02111-1307, USA. | |
257 | 30 |
12700
b3a8ee2da96a
Add keywords and comments as per conventions.
Richard M. Stallman <rms@gnu.org>
parents:
12028
diff
changeset
|
31 ;;; Commentary: |
14169 | 32 |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
33 ;; Major mode for editing and validating BibTeX files. |
257 | 34 |
12700
b3a8ee2da96a
Add keywords and comments as per conventions.
Richard M. Stallman <rms@gnu.org>
parents:
12028
diff
changeset
|
35 ;; Usage: |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
36 ;; See documentation for function bibtex-mode (or type "\M-x describe-mode" |
19461 | 37 ;; when you are in BibTeX mode). |
2602
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
38 |
12700
b3a8ee2da96a
Add keywords and comments as per conventions.
Richard M. Stallman <rms@gnu.org>
parents:
12028
diff
changeset
|
39 ;; Todo: |
b3a8ee2da96a
Add keywords and comments as per conventions.
Richard M. Stallman <rms@gnu.org>
parents:
12028
diff
changeset
|
40 ;; Distribute texinfo file. |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
41 |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
42 ;;; Code: |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
43 |
26711
eac840d283b6
(bibtex-hs-forward-sexp): Added to support
Gerd Moellmann <gerd@gnu.org>
parents:
25444
diff
changeset
|
44 |
12700
b3a8ee2da96a
Add keywords and comments as per conventions.
Richard M. Stallman <rms@gnu.org>
parents:
12028
diff
changeset
|
45 ;; User Options: |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
46 |
19460 | 47 (defgroup bibtex nil |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
48 "BibTeX mode" |
19460 | 49 :group 'tex |
50 :prefix "bibtex-") | |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
51 |
19460 | 52 (defgroup bibtex-autokey nil |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
53 "Generate automatically a key from the author/editor and the title field" |
19460 | 54 :group 'bibtex |
20907
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
55 :prefix "bibtex-autokey-") |
19460 | 56 |
57 (defcustom bibtex-mode-hook nil | |
58 "List of functions to call on entry to BibTeX mode." | |
59 :group 'bibtex | |
20907
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
60 :type 'hook) |
19460 | 61 |
62 (defcustom bibtex-field-delimiters 'braces | |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
63 "*Type of field delimiters. Allowed values are `braces' or `double-quotes'." |
19460 | 64 :group 'bibtex |
65 :type '(choice (const braces) | |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
66 (const double-quotes))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
67 |
19460 | 68 (defcustom bibtex-entry-delimiters 'braces |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
69 "*Type of entry delimiters. Allowed values are `braces' or `parentheses'." |
19460 | 70 :group 'bibtex |
71 :type '(choice (const braces) | |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
72 (const parentheses))) |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
73 |
19460 | 74 (defcustom bibtex-include-OPTcrossref '("InProceedings" "InCollection") |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
75 "*List of entries that get an OPTcrossref field." |
19460 | 76 :group 'bibtex |
77 :type '(repeat string)) | |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
78 |
19460 | 79 (defcustom bibtex-include-OPTkey t |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
80 "*If non-nil, all entries will have an OPTkey field. |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
81 If this is a string, it will be used as the initial field text. |
19460 | 82 If this is a function, it will be called to generate the initial field text." |
83 :group 'bibtex | |
84 :type '(choice (const :tag "None" nil) | |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
85 (string :tag "Initial text") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
86 (function :tag "Initialize Function" :value fun) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
87 (other :tag "Default" t))) |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
88 |
19460 | 89 (defcustom bibtex-user-optional-fields |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
90 '(("annote" "Personal annotation (ignored)")) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
91 "*List of optional fields the user wants to have always present. |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
92 Entries should be of the same form as the OPTIONAL and |
19461 | 93 CROSSREF-OPTIONAL lists in `bibtex-entry-field-alist' (see documentation |
19460 | 94 of this variable for details)." |
95 :group 'bibtex | |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
96 :type '(repeat (group (string :tag "Field") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
97 (string :tag "Comment") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
98 (option (group :inline t |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
99 :extra-offset -4 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
100 (choice :tag "Init" :value "" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
101 string |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
102 function)))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
103 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
104 (defcustom bibtex-entry-format |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
105 '(opts-or-alts required-fields numerical-fields) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
106 "*Type of formatting performed by `bibtex-clean-entry'. |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
107 It may be t, nil, or a list of symbols out of the following: |
19461 | 108 opts-or-alts Delete empty optional and alternative fields and |
109 remove OPT and ALT prefixes from used fields. | |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
110 required-fields Signal an error if a required field is missing. |
19461 | 111 numerical-fields Delete delimiters around numeral fields. |
112 page-dashes Change double dashes in page field to single dash | |
113 (for scribe compatibility). | |
114 inherit-booktitle If entry contains a crossref field and booktitle | |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
115 field is empty, it is set to the contents of the |
19461 | 116 title field of the crossreferenced entry. |
117 Caution: this will work only if buffer is | |
118 correctly sorted. | |
119 realign Realign entries, so that field texts and perhaps equal | |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
120 signs (depending on the value of |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
121 `bibtex-align-at-equal-sign') begin in the same column. |
19461 | 122 last-comma Add or delete comma on end of last field in entry, |
123 according to value of `bibtex-comma-after-last-field'. | |
124 delimiters Change delimiters according to variables | |
125 `bibtex-field-delimiters' and `bibtex-entry-delimiters'. | |
126 unify-case Change case of entry and field names. | |
127 | |
128 The value t means do all of the above formatting actions. | |
129 The value nil means do no formatting at all." | |
19460 | 130 :group 'bibtex |
131 :type '(choice (const :tag "None" nil) | |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
132 (const :tag "All" t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
133 (set :menu-tag "Some" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
134 (const opts-or-alts) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
135 (const required-fields) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
136 (const numerical-fields) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
137 (const page-dashes) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
138 (const inherit-booktitle) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
139 (const realign) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
140 (const last-comma) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
141 (const delimiters) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
142 (const unify-case)))) |
257 | 143 |
19460 | 144 (defcustom bibtex-clean-entry-hook nil |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
145 "*List of functions to call when entry has been cleaned. |
19461 | 146 Functions are called with point inside the cleaned entry, and the buffer |
19460 | 147 narrowed to just the entry." |
148 :group 'bibtex | |
20907
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
149 :type 'hook) |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
150 |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
151 (defcustom bibtex-maintain-sorted-entries nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
152 "*If non-nil, BibTeX mode maintains all BibTeX entries in sorted order. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
153 If it is nil this will strip off some comfort (e.g., TAB |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
154 completion for reference keys in minibuffer, automatic detection of |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
155 duplicates) from BibTeX mode. Allowed non-nil values are: |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
156 plain All entries are sorted alphabetically. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
157 crossref All entries are sorted alphabetically unless an entry has a |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
158 crossref field. These crossrefed entries are placed in |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
159 alphabetical order immediately preceding the main entry. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
160 entry-class The entries are divided into classes according to their |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
161 entry name, see `bibtex-sort-entry-class'. Within each class |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
162 the entries are sorted alphabetically. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
163 See also `bibtex-sort-ignore-string-entries'." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
164 :group 'bibtex |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
165 :type '(choice (const nil) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
166 (const plain) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
167 (const crossref) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
168 (const entry-class))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
169 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
170 (defvar bibtex-sort-entry-class |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
171 '(("String") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
172 ("Article" "InBook" "InCollection" "InProceedings") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
173 ("Book" "Proceedings") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
174 ("Booklet" "Manual" "MastersThesis" "PhdThesis" "TechReport" ) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
175 ("Misc" "Unpublished")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
176 "*List of classes of BibTeX entry names, used for sorting entries. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
177 Each class contains a list of entry names. If value of |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
178 `bibtex-maintain-sorted-entries' is `entry-class' entries are ordered |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
179 according to the classes they belong to.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
180 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
181 (defcustom bibtex-sort-ignore-string-entries |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
182 (not (equal bibtex-maintain-sorted-entries 'entry-class)) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
183 "*If non-nil, BibTeX @String entries are not sort-significant. |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
184 That means they are ignored when determining ordering of the buffer |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
185 \(e.g., sorting, locating alphabetical position for new entries, etc.)." |
19460 | 186 :group 'bibtex |
187 :type 'boolean) | |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
188 |
19460 | 189 (defcustom bibtex-field-kill-ring-max 20 |
19461 | 190 "*Max length of `bibtex-field-kill-ring' before discarding oldest elements." |
19460 | 191 :group 'bibtex |
192 :type 'integer) | |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
193 |
19460 | 194 (defcustom bibtex-parse-keys-timeout 60 |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
195 "*Specify interval for parsing BibTeX buffers. |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
196 All BibTeX buffers in Emacs are parsed if Emacs has been idle |
19461 | 197 `bibtex-parse-keys-timeout' seconds. Only buffers which were modified |
19460 | 198 after last parsing and which are maintained in sorted order are parsed." |
199 :group 'bibtex | |
200 :type 'integer) | |
15637
405b1ecbf8ba
(bibtex-reference-head): Allow spaces and tabs between
Karl Heuer <kwzh@gnu.org>
parents:
15565
diff
changeset
|
201 |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
202 (defvar bibtex-entry-field-alist |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
203 '( |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
204 ("Article" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
205 ((("author" "Author1 [and Author2 ...] [and others]") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
206 ("title" "Title of the article (BibTeX converts it to lowercase)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
207 ("journal" "Name of the journal (use string, remove braces)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
208 ("year" "Year of publication")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
209 (("volume" "Volume of the journal") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
210 ("number" "Number of the journal (only allowed if entry contains volume)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
211 ("pages" "Pages in the journal") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
212 ("month" "Month of the publication as a string (remove braces)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
213 ("note" "Remarks to be put at the end of the \\bibitem"))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
214 ((("author" "Author1 [and Author2 ...] [and others]") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
215 ("title" "Title of the article (BibTeX converts it to lowercase)")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
216 (("pages" "Pages in the journal") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
217 ("journal" "Name of the journal (use string, remove braces)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
218 ("year" "Year of publication") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
219 ("volume" "Volume of the journal") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
220 ("number" "Number of the journal") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
221 ("month" "Month of the publication as a string (remove braces)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
222 ("note" "Remarks to be put at the end of the \\bibitem")))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
223 ("Book" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
224 ((("author" "Author1 [and Author2 ...] [and others]" "" t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
225 ("editor" "Editor1 [and Editor2 ...] [and others]" "" t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
226 ("title" "Title of the book") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
227 ("publisher" "Publishing company") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
228 ("year" "Year of publication")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
229 (("volume" "Volume of the book in the series") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
230 ("number" "Number of the book in a small series (overwritten by volume)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
231 ("series" "Series in which the book appeared") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
232 ("address" "Address of the publisher") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
233 ("edition" "Edition of the book as a capitalized English word") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
234 ("month" "Month of the publication as a string (remove braces)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
235 ("note" "Remarks to be put at the end of the \\bibitem"))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
236 ((("author" "Author1 [and Author2 ...] [and others]" "" t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
237 ("editor" "Editor1 [and Editor2 ...] [and others]" "" t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
238 ("title" "Title of the book")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
239 (("publisher" "Publishing company") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
240 ("year" "Year of publication") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
241 ("volume" "Volume of the book in the series") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
242 ("number" "Number of the book in a small series (overwritten by volume)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
243 ("series" "Series in which the book appeared") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
244 ("address" "Address of the publisher") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
245 ("edition" "Edition of the book as a capitalized English word") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
246 ("month" "Month of the publication as a string (remove braces)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
247 ("note" "Remarks to be put at the end of the \\bibitem")))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
248 ("Booklet" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
249 ((("title" "Title of the booklet (BibTeX converts it to lowercase)")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
250 (("author" "Author1 [and Author2 ...] [and others]") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
251 ("howpublished" "The way in which the booklet was published") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
252 ("address" "Address of the publisher") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
253 ("month" "Month of the publication as a string (remove braces)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
254 ("year" "Year of publication") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
255 ("note" "Remarks to be put at the end of the \\bibitem")))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
256 ("InBook" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
257 ((("author" "Author1 [and Author2 ...] [and others]" "" t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
258 ("editor" "Editor1 [and Editor2 ...] [and others]" "" t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
259 ("title" "Title of the book") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
260 ("chapter" "Chapter in the book") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
261 ("publisher" "Publishing company") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
262 ("year" "Year of publication")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
263 (("volume" "Volume of the book in the series") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
264 ("number" "Number of the book in a small series (overwritten by volume)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
265 ("series" "Series in which the book appeared") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
266 ("type" "Word to use instead of \"chapter\"") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
267 ("address" "Address of the publisher") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
268 ("edition" "Edition of the book as a capitalized English word") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
269 ("month" "Month of the publication as a string (remove braces)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
270 ("pages" "Pages in the book") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
271 ("note" "Remarks to be put at the end of the \\bibitem"))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
272 ((("author" "Author1 [and Author2 ...] [and others]" "" t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
273 ("editor" "Editor1 [and Editor2 ...] [and others]" "" t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
274 ("title" "Title of the book") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
275 ("chapter" "Chapter in the book")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
276 (("pages" "Pages in the book") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
277 ("publisher" "Publishing company") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
278 ("year" "Year of publication") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
279 ("volume" "Volume of the book in the series") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
280 ("number" "Number of the book in a small series (overwritten by volume)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
281 ("series" "Series in which the book appeared") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
282 ("type" "Word to use instead of \"chapter\"") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
283 ("address" "Address of the publisher") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
284 ("edition" "Edition of the book as a capitalized English word") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
285 ("month" "Month of the publication as a string (remove braces)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
286 ("note" "Remarks to be put at the end of the \\bibitem")))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
287 ("InCollection" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
288 ((("author" "Author1 [and Author2 ...] [and others]") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
289 ("title" "Title of the article in book (BibTeX converts it to lowercase)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
290 ("booktitle" "Name of the book") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
291 ("publisher" "Publishing company") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
292 ("year" "Year of publication")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
293 (("editor" "Editor1 [and Editor2 ...] [and others]") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
294 ("volume" "Volume of the book in the series") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
295 ("number" "Number of the book in a small series (overwritten by volume)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
296 ("series" "Series in which the book appeared") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
297 ("type" "Word to use instead of \"chapter\"") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
298 ("chapter" "Chapter in the book") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
299 ("pages" "Pages in the book") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
300 ("address" "Address of the publisher") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
301 ("edition" "Edition of the book as a capitalized English word") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
302 ("month" "Month of the publication as a string (remove braces)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
303 ("note" "Remarks to be put at the end of the \\bibitem"))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
304 ((("author" "Author1 [and Author2 ...] [and others]") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
305 ("title" "Title of the article in book (BibTeX converts it to lowercase)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
306 ("booktitle" "Name of the book")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
307 (("pages" "Pages in the book") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
308 ("publisher" "Publishing company") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
309 ("year" "Year of publication") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
310 ("editor" "Editor1 [and Editor2 ...] [and others]") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
311 ("volume" "Volume of the book in the series") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
312 ("number" "Number of the book in a small series (overwritten by volume)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
313 ("series" "Series in which the book appeared") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
314 ("type" "Word to use instead of \"chapter\"") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
315 ("chapter" "Chapter in the book") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
316 ("address" "Address of the publisher") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
317 ("edition" "Edition of the book as a capitalized English word") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
318 ("month" "Month of the publication as a string (remove braces)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
319 ("note" "Remarks to be put at the end of the \\bibitem")))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
320 ("InProceedings" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
321 ((("author" "Author1 [and Author2 ...] [and others]") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
322 ("title" "Title of the article in proceedings (BibTeX converts it to lowercase)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
323 ("booktitle" "Name of the conference proceedings") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
324 ("year" "Year of publication")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
325 (("editor" "Editor1 [and Editor2 ...] [and others]") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
326 ("volume" "Volume of the conference proceedings in the series") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
327 ("number" "Number of the conference proceedings in a small series (overwritten by volume)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
328 ("series" "Series in which the conference proceedings appeared") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
329 ("pages" "Pages in the conference proceedings") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
330 ("address" "Location of the Proceedings") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
331 ("month" "Month of the publication as a string (remove braces)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
332 ("organization" "Sponsoring organization of the conference") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
333 ("publisher" "Publishing company, its location") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
334 ("note" "Remarks to be put at the end of the \\bibitem"))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
335 ((("author" "Author1 [and Author2 ...] [and others]") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
336 ("title" "Title of the article in proceedings (BibTeX converts it to lowercase)")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
337 (("booktitle" "Name of the conference proceedings") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
338 ("pages" "Pages in the conference proceedings") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
339 ("year" "Year of publication") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
340 ("editor" "Editor1 [and Editor2 ...] [and others]") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
341 ("volume" "Volume of the conference proceedings in the series") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
342 ("number" "Number of the conference proceedings in a small series (overwritten by volume)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
343 ("series" "Series in which the conference proceedings appeared") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
344 ("address" "Location of the Proceedings") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
345 ("month" "Month of the publication as a string (remove braces)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
346 ("organization" "Sponsoring organization of the conference") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
347 ("publisher" "Publishing company, its location") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
348 ("note" "Remarks to be put at the end of the \\bibitem")))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
349 ("Manual" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
350 ((("title" "Title of the manual")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
351 (("author" "Author1 [and Author2 ...] [and others]") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
352 ("organization" "Publishing organization of the manual") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
353 ("address" "Address of the organization") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
354 ("edition" "Edition of the manual as a capitalized English word") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
355 ("month" "Month of the publication as a string (remove braces)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
356 ("year" "Year of publication") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
357 ("note" "Remarks to be put at the end of the \\bibitem")))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
358 ("MastersThesis" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
359 ((("author" "Author1 [and Author2 ...] [and others]") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
360 ("title" "Title of the master\'s thesis (BibTeX converts it to lowercase)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
361 ("school" "School where the master\'s thesis was written") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
362 ("year" "Year of publication")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
363 (("type" "Type of the master\'s thesis (if other than \"Master\'s thesis\")") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
364 ("address" "Address of the school (if not part of field \"school\") or country") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
365 ("month" "Month of the publication as a string (remove braces)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
366 ("note" "Remarks to be put at the end of the \\bibitem")))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
367 ("Misc" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
368 (() |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
369 (("author" "Author1 [and Author2 ...] [and others]") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
370 ("title" "Title of the work (BibTeX converts it to lowercase)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
371 ("howpublished" "The way in which the work was published") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
372 ("month" "Month of the publication as a string (remove braces)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
373 ("year" "Year of publication") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
374 ("note" "Remarks to be put at the end of the \\bibitem")))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
375 ("PhdThesis" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
376 ((("author" "Author1 [and Author2 ...] [and others]") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
377 ("title" "Title of the PhD. thesis") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
378 ("school" "School where the PhD. thesis was written") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
379 ("year" "Year of publication")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
380 (("type" "Type of the PhD. thesis") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
381 ("address" "Address of the school (if not part of field \"school\") or country") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
382 ("month" "Month of the publication as a string (remove braces)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
383 ("note" "Remarks to be put at the end of the \\bibitem")))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
384 ("Proceedings" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
385 ((("title" "Title of the conference proceedings") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
386 ("year" "Year of publication")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
387 (("booktitle" "Title of the proceedings for cross references") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
388 ("editor" "Editor1 [and Editor2 ...] [and others]") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
389 ("volume" "Volume of the conference proceedings in the series") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
390 ("number" "Number of the conference proceedings in a small series (overwritten by volume)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
391 ("series" "Series in which the conference proceedings appeared") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
392 ("address" "Location of the Proceedings") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
393 ("month" "Month of the publication as a string (remove braces)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
394 ("organization" "Sponsoring organization of the conference") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
395 ("publisher" "Publishing company, its location") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
396 ("note" "Remarks to be put at the end of the \\bibitem")))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
397 ("TechReport" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
398 ((("author" "Author1 [and Author2 ...] [and others]") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
399 ("title" "Title of the technical report (BibTeX converts it to lowercase)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
400 ("institution" "Sponsoring institution of the report") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
401 ("year" "Year of publication")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
402 (("type" "Type of the report (if other than \"technical report\")") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
403 ("number" "Number of the technical report") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
404 ("address" "Address of the institution (if not part of field \"institution\") or country") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
405 ("month" "Month of the publication as a string (remove braces)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
406 ("note" "Remarks to be put at the end of the \\bibitem")))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
407 ("Unpublished" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
408 ((("author" "Author1 [and Author2 ...] [and others]") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
409 ("title" "Title of the unpublished work (BibTeX converts it to lowercase)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
410 ("note" "Remarks to be put at the end of the \\bibitem")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
411 (("month" "Month of the publication as a string (remove braces)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
412 ("year" "Year of publication")))) |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
413 ) |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
414 |
27701
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
415 "Defines entry types and their associated fields. |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
416 List of |
43950
5ef8be2a8db1
(bibtex-sort-ignore-string-entries)
Pavel Janík <Pavel@Janik.cz>
parents:
43758
diff
changeset
|
417 \(ENTRY-NAME (REQUIRED OPTIONAL) (CROSSREF-REQUIRED CROSSREF-OPTIONAL)) |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
418 triples. |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
419 If the third element is nil, the first pair is always used. |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
420 If not, the second pair is used in the case of presence of a crossref |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
421 field and the third in the case of absence. |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
422 REQUIRED, OPTIONAL, CROSSREF-REQUIRED and CROSSREF-OPTIONAL are lists. |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
423 Each element of these lists is a list of the form |
43950
5ef8be2a8db1
(bibtex-sort-ignore-string-entries)
Pavel Janík <Pavel@Janik.cz>
parents:
43758
diff
changeset
|
424 \(FIELD-NAME COMMENT-STRING INIT ALTERNATIVE-FLAG). |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
425 COMMENT-STRING, INIT, and ALTERNATIVE-FLAG are optional. |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
426 FIELD-NAME is the name of the field, COMMENT-STRING the comment to |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
427 appear in the echo area, INIT is either the initial content of the |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
428 field or a function, which is called to determine the initial content |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
429 of the field, and ALTERNATIVE-FLAG (either nil or t) marks if the |
19461 | 430 field is an alternative. ALTERNATIVE-FLAG may be t only in the |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
431 REQUIRED or CROSSREF-REQUIRED lists.") |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
432 |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
433 (defvar bibtex-comment-start "@Comment" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
434 "String starting a BibTeX comment.") |
20907
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
435 |
19460 | 436 (defcustom bibtex-add-entry-hook nil |
437 "List of functions to call when entry has been inserted." | |
438 :group 'bibtex | |
20907
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
439 :type 'hook) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
440 |
19460 | 441 (defcustom bibtex-predefined-month-strings |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
442 '(("jan" . "January") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
443 ("feb" . "February") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
444 ("mar" . "March") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
445 ("apr" . "April") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
446 ("may" . "May") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
447 ("jun" . "June") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
448 ("jul" . "July") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
449 ("aug" . "August") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
450 ("sep" . "September") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
451 ("oct" . "October") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
452 ("nov" . "November") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
453 ("dec" . "December")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
454 "Alist of month string definitions used in the BibTeX style files. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
455 Each element is a pair of strings (ABBREVIATION EXPANSION)." |
19460 | 456 :group 'bibtex |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
457 :type '(repeat (cons (string :tag "Month abbreviation") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
458 (string :tag "Month expansion")))) |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
459 |
19460 | 460 (defcustom bibtex-predefined-strings |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
461 (append |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
462 bibtex-predefined-month-strings |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
463 '(("acmcs" . "ACM Computing Surveys") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
464 ("acta" . "Acta Informatica") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
465 ("cacm" . "Communications of the ACM") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
466 ("ibmjrd" . "IBM Journal of Research and Development") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
467 ("ibmsj" . "IBM Systems Journal") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
468 ("ieeese" . "IEEE Transactions on Software Engineering") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
469 ("ieeetc" . "IEEE Transactions on Computers") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
470 ("ieeetcad" . "IEEE Transactions on Computer-Aided Design of Integrated Circuits") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
471 ("ipl" . "Information Processing Letters") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
472 ("jacm" . "Journal of the ACM") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
473 ("jcss" . "Journal of Computer and System Sciences") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
474 ("scp" . "Science of Computer Programming") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
475 ("sicomp" . "SIAM Journal on Computing") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
476 ("tcs" . "Theoretical Computer Science") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
477 ("tocs" . "ACM Transactions on Computer Systems") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
478 ("tods" . "ACM Transactions on Database Systems") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
479 ("tog" . "ACM Transactions on Graphics") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
480 ("toms" . "ACM Transactions on Mathematical Software") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
481 ("toois" . "ACM Transactions on Office Information Systems") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
482 ("toplas" . "ACM Transactions on Programming Languages and Systems"))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
483 "Alist of string definitions used in the BibTeX style files. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
484 Each element is a pair of strings (ABBREVIATION EXPANSION)." |
19460 | 485 :group 'bibtex |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
486 :type '(repeat (cons (string :tag "String") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
487 (string :tag "String expansion")))) |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
488 |
19460 | 489 (defcustom bibtex-string-files nil |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
490 "*List of BibTeX files containing string definitions. |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
491 Those files must be specified using pathnames relative to the |
19461 | 492 directories specified in `bibtex-string-file-path'. This variable is only |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
493 evaluated when BibTeX mode is entered (i.e., when loading the BibTeX |
19460 | 494 file)." |
495 :group 'bibtex | |
496 :type '(repeat file)) | |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
497 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
498 (defvar bibtex-string-file-path (getenv "BIBINPUTS") |
26711
eac840d283b6
(bibtex-hs-forward-sexp): Added to support
Gerd Moellmann <gerd@gnu.org>
parents:
25444
diff
changeset
|
499 "*Colon separated list of paths to search for `bibtex-string-files'.") |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
500 |
19460 | 501 (defcustom bibtex-help-message t |
502 "*If not nil print help messages in the echo area on entering a new field." | |
503 :group 'bibtex | |
504 :type 'boolean) | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
505 |
19460 | 506 (defcustom bibtex-autokey-prefix-string "" |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
507 "*String to use as a prefix for all generated keys. |
19461 | 508 See the documentation of function `bibtex-generate-autokey' for more detail." |
19460 | 509 :group 'bibtex-autokey |
510 :type 'string) | |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
511 |
19460 | 512 (defcustom bibtex-autokey-names 1 |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
513 "*Number of names to use for the automatically generated reference key. |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
514 If this variable is nil, all names are used. |
19461 | 515 Possibly more names are used according to `bibtex-autokey-names-stretch'. |
516 See the documentation of function `bibtex-generate-autokey' for more detail." | |
19460 | 517 :group 'bibtex-autokey |
20907
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
518 :type '(choice (const :tag "All" infty) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
519 integer)) |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
520 |
19460 | 521 (defcustom bibtex-autokey-names-stretch 0 |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
522 "*Number of names that can additionally be used. |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
523 These names are used only, if all names are used then. |
19461 | 524 See the documentation of function `bibtex-generate-autokey' for details." |
19460 | 525 :group 'bibtex-autokey |
526 :type 'integer) | |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
527 |
19460 | 528 (defcustom bibtex-autokey-additional-names "" |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
529 "*String to prepend to the generated key if not all names could be used. |
19461 | 530 See the documentation of function `bibtex-generate-autokey' for details." |
19460 | 531 :group 'bibtex-autokey |
532 :type 'string) | |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
533 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
534 (defvar bibtex-autokey-transcriptions |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
535 '(;; language specific characters |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
536 ("\\\\aa" . "a") ; \aa -> a |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
537 ("\\\\AA" . "A") ; \AA -> A |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
538 ("\\\"a\\|\\\\\\\"a\\|\\\\ae" . "ae") ; "a,\"a,\ae -> ae |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
539 ("\\\"A\\|\\\\\\\"A\\|\\\\AE" . "Ae") ; "A,\"A,\AE -> Ae |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
540 ("\\\\i" . "i") ; \i -> i |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
541 ("\\\\j" . "j") ; \j -> j |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
542 ("\\\\l" . "l") ; \l -> l |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
543 ("\\\\L" . "L") ; \L -> L |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
544 ("\\\"o\\|\\\\\\\"o\\|\\\\o\\|\\\\oe" . "oe") ; "o,\"o,\o,\oe -> oe |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
545 ("\\\"O\\|\\\\\\\"O\\|\\\\O\\|\\\\OE" . "Oe") ; "O,\"O,\O,\OE -> Oe |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
546 ("\\\"s\\|\\\\\\\"s\\|\\\\3" . "ss") ; "s,\"s,\3 -> ss |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
547 ("\\\"u\\|\\\\\\\"u" . "ue") ; "u,\"u -> ue |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
548 ("\\\"U\\|\\\\\\\"U" . "Ue") ; "U,\"U -> Ue |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
549 ;; accents |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
550 ("\\\\`\\|\\\\'\\|\\\\\\^\\|\\\\~\\|\\\\=\\|\\\\\\.\\|\\\\u\\|\\\\v\\|\\\\H\\|\\\\t\\|\\\\c\\|\\\\d\\|\\\\b" . "") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
551 ("`\\|'\\|\\\"" . "") |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
552 ;; braces |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
553 ("{" . "") ("}" . "") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
554 ;; spaces |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
555 ("[ \t\n]+" . " ")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
556 "Alist of (OLD-REGEXP NEW-STRING) pairs. |
19461 | 557 Used by the default values of `bibtex-autokey-name-change-strings' and |
558 `bibtex-autokey-titleword-change-strings'. Defaults to translating some | |
559 language specific characters to their ASCII transcriptions, and | |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
560 removing any character accents.") |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
561 |
19460 | 562 (defcustom bibtex-autokey-name-change-strings |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
563 bibtex-autokey-transcriptions |
19461 | 564 "Alist of (OLD-REGEXP NEW-STRING) pairs. |
565 Any part of name matching a OLD-REGEXP is replaced by NEW-STRING. | |
566 Case is significant in OLD-REGEXP. All regexps are tried in the | |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
567 order in which they appear in the list. |
19461 | 568 See the documentation of function `bibtex-generate-autokey' for details." |
19460 | 569 :group 'bibtex-autokey |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
570 :type '(repeat (cons (regexp :tag "Old") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
571 (string :tag "New")))) |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
572 |
20907
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
573 (defcustom bibtex-autokey-name-case-convert 'downcase |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
574 "*Function called for each name to perform case conversion. |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
575 See the documentation of function `bibtex-generate-autokey' for details." |
20907
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
576 :group 'bibtex-autokey |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
577 :type '(choice (const :tag "Preserve case" identity) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
578 (const :tag "Downcase" downcase) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
579 (const :tag "Capitalize" capitalize) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
580 (const :tag "Upcase" upcase) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
581 (function :tag "Conversion function"))) |
20907
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
582 |
19460 | 583 (defcustom bibtex-autokey-name-length 'infty |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
584 "*Number of characters from name to incorporate into key. |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
585 If this is set to anything but a number, all characters are used. |
19461 | 586 See the documentation of function `bibtex-generate-autokey' for details." |
19460 | 587 :group 'bibtex-autokey |
588 :type '(choice (const :tag "All" infty) | |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
589 integer)) |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
590 |
19460 | 591 (defcustom bibtex-autokey-name-separator "" |
592 "*String that comes between any two names in the key. | |
19461 | 593 See the documentation of function `bibtex-generate-autokey' for details." |
19460 | 594 :group 'bibtex-autokey |
595 :type 'string) | |
596 | |
597 (defcustom bibtex-autokey-year-length 2 | |
20866
2501e131622d
(bibtex-autokey-year-length): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
598 "*Number of rightmost digits from the year field to incorporate into key. |
19461 | 599 See the documentation of function `bibtex-generate-autokey' for details." |
19460 | 600 :group 'bibtex-autokey |
601 :type 'integer) | |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
602 |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
603 (defcustom bibtex-autokey-use-crossref t |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
604 "*If non-nil use fields from crossreferenced entry if necessary. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
605 If this variable is non-nil and some field has no entry, but a |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
606 valid crossref entry, the field from the crossreferenced entry is used. |
19461 | 607 See the documentation of function `bibtex-generate-autokey' for details." |
19460 | 608 :group 'bibtex-autokey |
609 :type 'boolean) | |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
610 |
19460 | 611 (defcustom bibtex-autokey-titlewords 5 |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
612 "*Number of title words to use for the automatically generated reference key. |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
613 If this is set to anything but a number, all title words are used. |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
614 Possibly more words from the title are used according to |
19461 | 615 `bibtex-autokey-titlewords-stretch'. |
616 See the documentation of function `bibtex-generate-autokey' for details." | |
19460 | 617 :group 'bibtex-autokey |
618 :type '(choice (const :tag "All" infty) | |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
619 integer)) |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
620 |
19460 | 621 (defcustom bibtex-autokey-title-terminators |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
622 '("\\." "!" "\\?" ":" ";" "--") |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
623 "*Regexp list defining the termination of the main part of the title. |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
624 Case of the regexps is ignored. |
19461 | 625 See the documentation of function `bibtex-generate-autokey' for details." |
19460 | 626 :group 'bibtex-autokey |
627 :type '(repeat regexp)) | |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
628 |
19460 | 629 (defcustom bibtex-autokey-titlewords-stretch 2 |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
630 "*Number of words that can additionally be used from the title. |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
631 These words are used only, if a sentence from the title can be ended then. |
19461 | 632 See the documentation of function `bibtex-generate-autokey' for details." |
19460 | 633 :group 'bibtex-autokey |
634 :type 'integer) | |
2602
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
635 |
20907
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
636 (defcustom bibtex-autokey-titleword-ignore |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
637 '("A" "An" "On" "The" "Eine?" "Der" "Die" "Das" |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
638 "[^A-Z].*" ".*[^a-zA-Z0-9].*") |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
639 "*Determines words from the title that are not to be used in the key. |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
640 Each item of the list is a regexp. If a word of the title matchs a |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
641 regexp from that list, it is not included in the title part of the key. |
19461 | 642 See the documentation of function `bibtex-generate-autokey' for details." |
19460 | 643 :group 'bibtex-autokey |
644 :type '(repeat regexp)) | |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
645 |
20907
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
646 (defcustom bibtex-autokey-titleword-case-convert 'downcase |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
647 "*Function called for each titleword to perform case conversion. |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
648 See the documentation of function `bibtex-generate-autokey' for details." |
20907
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
649 :group 'bibtex-autokey |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
650 :type '(choice (const :tag "Preserve case" identity) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
651 (const :tag "Downcase" downcase) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
652 (const :tag "Capitalize" capitalize) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
653 (const :tag "Upcase" upcase) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
654 (function :tag "Conversion function"))) |
20907
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
655 |
19460 | 656 (defcustom bibtex-autokey-titleword-abbrevs nil |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
657 "*Determines exceptions to the usual abbreviation mechanism. |
19461 | 658 An alist of (OLD-REGEXP NEW-STRING) pairs. Case is ignored |
659 in matching against OLD-REGEXP, and the first matching pair is used. | |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
660 See the documentation of function `bibtex-generate-autokey' for details." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
661 :group 'bibtex-autokey |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
662 :type '(repeat (cons (regexp :tag "Old") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
663 (string :tag "New")))) |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
664 |
19460 | 665 (defcustom bibtex-autokey-titleword-change-strings |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
666 bibtex-autokey-transcriptions |
19461 | 667 "Alist of (OLD-REGEXP NEW-STRING) pairs. |
668 Any part of title word matching a OLD-REGEXP is replaced by NEW-STRING. | |
669 Case is significant in OLD-REGEXP. All regexps are tried in the | |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
670 order in which they appear in the list. |
19461 | 671 See the documentation of function `bibtex-generate-autokey' for details." |
19460 | 672 :group 'bibtex-autokey |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
673 :type '(repeat (cons (regexp :tag "Old") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
674 (string :tag "New")))) |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
675 |
19460 | 676 (defcustom bibtex-autokey-titleword-length 5 |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
677 "*Number of characters from title words to incorporate into key. |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
678 If this is set to anything but a number, all characters are used. |
19461 | 679 See the documentation of function `bibtex-generate-autokey' for details." |
19460 | 680 :group 'bibtex-autokey |
681 :type '(choice (const :tag "All" infty) | |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
682 integer)) |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
683 |
19460 | 684 (defcustom bibtex-autokey-titleword-separator "_" |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
685 "*String to be put between the title words. |
19461 | 686 See the documentation of function `bibtex-generate-autokey' for details." |
19460 | 687 :group 'bibtex-autokey |
688 :type 'string) | |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
689 |
19460 | 690 (defcustom bibtex-autokey-name-year-separator "" |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
691 "*String to be put between name part and year part of key. |
19461 | 692 See the documentation of function `bibtex-generate-autokey' for details." |
19460 | 693 :group 'bibtex-autokey |
694 :type 'string) | |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
695 |
19460 | 696 (defcustom bibtex-autokey-year-title-separator ":_" |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
697 "*String to be put between name part and year part of key. |
19461 | 698 See the documentation of function `bibtex-generate-autokey' for details." |
19460 | 699 :group 'bibtex-autokey |
700 :type 'string) | |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
701 |
19460 | 702 (defcustom bibtex-autokey-edit-before-use t |
703 "*If non-nil, user is allowed to edit the generated key before it is used." | |
704 :group 'bibtex-autokey | |
705 :type 'boolean) | |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
706 |
20907
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
707 (defcustom bibtex-autokey-before-presentation-function nil |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
708 "*Function to call before the generated key is presented. |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
709 If non-nil this should be a single function, which is called before |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
710 the generated key is presented (in entry or, if |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
711 `bibtex-autokey-edit-before-use' is t, in minibuffer). This function |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
712 must take one argument (the automatically generated key), and must |
19460 | 713 return with a string (the key to use)." |
714 :group 'bibtex-autokey | |
35962
ad7104908c16
(bibtex-autokey-before-presentation-function): Fix :type.
Dave Love <fx@gnu.org>
parents:
27701
diff
changeset
|
715 :type '(choice (const nil) function)) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
716 |
19460 | 717 (defcustom bibtex-entry-offset 0 |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
718 "*Offset for BibTeX entries. |
19460 | 719 Added to the value of all other variables which determine colums." |
720 :group 'bibtex | |
721 :type 'integer) | |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
722 |
19460 | 723 (defcustom bibtex-field-indentation 2 |
724 "*Starting column for the name part in BibTeX fields." | |
725 :group 'bibtex | |
726 :type 'integer) | |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
727 |
19460 | 728 (defcustom bibtex-text-indentation |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
729 (+ bibtex-field-indentation |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
730 (length "organization = ")) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
731 "*Starting column for the text part in BibTeX fields. |
19460 | 732 Should be equal to the space needed for the longest name part." |
733 :group 'bibtex | |
734 :type 'integer) | |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
735 |
19460 | 736 (defcustom bibtex-contline-indentation |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
737 (+ bibtex-text-indentation 1) |
19460 | 738 "*Starting column for continuation lines of BibTeX fields." |
739 :group 'bibtex | |
740 :type 'integer) | |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
741 |
19460 | 742 (defcustom bibtex-align-at-equal-sign nil |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
743 "*If non-nil, align fields at equal sign instead of field text. |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
744 If non-nil, the column for the equal sign is the value of |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
745 `bibtex-text-indentation', minus 2." |
19460 | 746 :group 'bibtex |
747 :type 'boolean) | |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
748 |
19460 | 749 (defcustom bibtex-comma-after-last-field nil |
750 "*If non-nil, a comma is put at end of last field in the entry template." | |
751 :group 'bibtex | |
752 :type 'boolean) | |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
753 |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
754 (defcustom bibtex-complete-key-cleanup nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
755 "*Function called by `bibtex-complete' after insertion of a key fragment." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
756 :group 'bibtex-autokey |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
757 :type '(choice (const :tag "None" nil) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
758 (function :tag "Cleanup function"))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
759 |
14789
d68b71228abd
(bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents:
14410
diff
changeset
|
760 ;; bibtex-font-lock-keywords is a user option as well, but since the |
d68b71228abd
(bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents:
14410
diff
changeset
|
761 ;; patterns used to define this variable are defined in a later |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
762 ;; section of this file, it is defined later. |
26711
eac840d283b6
(bibtex-hs-forward-sexp): Added to support
Gerd Moellmann <gerd@gnu.org>
parents:
25444
diff
changeset
|
763 |
eac840d283b6
(bibtex-hs-forward-sexp): Added to support
Gerd Moellmann <gerd@gnu.org>
parents:
25444
diff
changeset
|
764 |
12700
b3a8ee2da96a
Add keywords and comments as per conventions.
Richard M. Stallman <rms@gnu.org>
parents:
12028
diff
changeset
|
765 ;; Syntax Table, Keybindings and BibTeX Entry List |
2602
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
766 (defvar bibtex-mode-syntax-table |
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
767 (let ((st (make-syntax-table))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
768 (modify-syntax-entry ?\" "\"" st) |
2602
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
769 (modify-syntax-entry ?$ "$$ " st) |
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
770 (modify-syntax-entry ?% "< " st) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
771 (modify-syntax-entry ?' "w " st) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
772 (modify-syntax-entry ?@ "w " st) |
2602
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
773 (modify-syntax-entry ?\\ "\\" st) |
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
774 (modify-syntax-entry ?\f "> " st) |
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
775 (modify-syntax-entry ?\n "> " st) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
776 ;; Keys cannot have = in them (wrong font-lock of @string{foo=bar}). |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
777 (modify-syntax-entry ?= "." st) |
2602
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
778 (modify-syntax-entry ?~ " " st) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
779 st) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
780 "Syntax table used in BibTeX mode buffers.") |
2602
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
781 |
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
782 (defvar bibtex-mode-map |
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
783 (let ((km (make-sparse-keymap))) |
26711
eac840d283b6
(bibtex-hs-forward-sexp): Added to support
Gerd Moellmann <gerd@gnu.org>
parents:
25444
diff
changeset
|
784 ;; The Key `C-c&' is reserved for reftex.el |
2602
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
785 (define-key km "\t" 'bibtex-find-text) |
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
786 (define-key km "\n" 'bibtex-next-field) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
787 (define-key km "\M-\t" 'bibtex-complete) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
788 (define-key km "\C-c\"" 'bibtex-remove-delimiters) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
789 (define-key km "\C-c{" 'bibtex-remove-delimiters) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
790 (define-key km "\C-c}" 'bibtex-remove-delimiters) |
2602
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
791 (define-key km "\C-c\C-c" 'bibtex-clean-entry) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
792 (define-key km "\C-c\C-q" 'bibtex-fill-entry) |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
793 (define-key km "\C-c?" 'bibtex-print-help-message) |
2602
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
794 (define-key km "\C-c\C-p" 'bibtex-pop-previous) |
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
795 (define-key km "\C-c\C-n" 'bibtex-pop-next) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
796 (define-key km "\C-c\C-k" 'bibtex-kill-field) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
797 (define-key km "\C-c\M-k" 'bibtex-copy-field-as-kill) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
798 (define-key km "\C-c\C-w" 'bibtex-kill-entry) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
799 (define-key km "\C-c\M-w" 'bibtex-copy-entry-as-kill) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
800 (define-key km "\C-c\C-y" 'bibtex-yank) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
801 (define-key km "\C-c\M-y" 'bibtex-yank-pop) |
2602
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
802 (define-key km "\C-c\C-d" 'bibtex-empty-field) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
803 (define-key km "\C-c\C-f" 'bibtex-make-field) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
804 (define-key km "\C-c$" 'bibtex-ispell-abstract) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
805 (define-key km "\M-\C-a" 'bibtex-beginning-of-entry) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
806 (define-key km "\M-\C-e" 'bibtex-end-of-entry) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
807 (define-key km "\C-\M-l" 'bibtex-reposition-window) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
808 (define-key km "\C-\M-h" 'bibtex-mark-entry) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
809 (define-key km "\C-c\C-b" 'bibtex-entry) |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
810 (define-key km "\C-c\C-rn" 'bibtex-narrow-to-entry) |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
811 (define-key km "\C-c\C-rw" 'widen) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
812 (define-key km "\C-c\C-o" 'bibtex-remove-OPT-or-ALT) |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
813 (define-key km "\C-c\C-e\C-i" 'bibtex-InProceedings) |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
814 (define-key km "\C-c\C-ei" 'bibtex-InCollection) |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
815 (define-key km "\C-c\C-eI" 'bibtex-InBook) |
2602
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
816 (define-key km "\C-c\C-e\C-a" 'bibtex-Article) |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
817 (define-key km "\C-c\C-e\C-b" 'bibtex-InBook) |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
818 (define-key km "\C-c\C-eb" 'bibtex-Book) |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
819 (define-key km "\C-c\C-eB" 'bibtex-Booklet) |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
820 (define-key km "\C-c\C-e\C-c" 'bibtex-InCollection) |
2602
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
821 (define-key km "\C-c\C-e\C-m" 'bibtex-Manual) |
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
822 (define-key km "\C-c\C-em" 'bibtex-MastersThesis) |
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
823 (define-key km "\C-c\C-eM" 'bibtex-Misc) |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
824 (define-key km "\C-c\C-e\C-p" 'bibtex-InProceedings) |
2602
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
825 (define-key km "\C-c\C-ep" 'bibtex-Proceedings) |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
826 (define-key km "\C-c\C-eP" 'bibtex-PhdThesis) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
827 (define-key km "\C-c\C-e\M-p" 'bibtex-Preamble) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
828 (define-key km "\C-c\C-e\C-s" 'bibtex-String) |
2602
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
829 (define-key km "\C-c\C-e\C-t" 'bibtex-TechReport) |
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
830 (define-key km "\C-c\C-e\C-u" 'bibtex-Unpublished) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
831 km) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
832 "Keymap used in BibTeX mode.") |
2602
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
833 |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
834 (easy-menu-define |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
835 bibtex-edit-menu bibtex-mode-map "BibTeX-Edit Menu in BibTeX mode" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
836 '("BibTeX-Edit" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
837 ("Moving inside an Entry" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
838 ["End of Field" bibtex-find-text t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
839 ["Next Field" bibtex-next-field t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
840 ["Beginning of Entry" bibtex-beginning-of-entry t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
841 ["End of Entry" bibtex-end-of-entry t]) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
842 ("Operating on Current Entry" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
843 ["Fill Entry" bibtex-fill-entry t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
844 ["Clean Entry" bibtex-clean-entry t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
845 "--" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
846 ["Kill Entry" bibtex-kill-entry t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
847 ["Copy Entry to Kill Ring" bibtex-copy-entry-as-kill t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
848 ["Paste Most Recently Killed Entry" bibtex-yank t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
849 ["Paste Previously Killed Entry" bibtex-yank-pop t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
850 "--" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
851 ["Ispell Entry" bibtex-ispell-entry t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
852 ["Ispell Entry Abstract" bibtex-ispell-abstract t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
853 ["Narrow to Entry" bibtex-narrow-to-entry t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
854 "--" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
855 ["View Cite Locations (RefTeX)" reftex-view-crossref-from-bibtex |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
856 (fboundp 'reftex-view-crossref-from-bibtex)]) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
857 ("Operating on Current Field" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
858 ["Remove Delimiters" bibtex-remove-delimiters t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
859 ["Remove OPT or ALT Prefix" bibtex-remove-OPT-or-ALT t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
860 ["Clear Field" bibtex-empty-field t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
861 "--" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
862 ["Kill Field" bibtex-kill-field t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
863 ["Copy Field to Kill Ring" bibtex-copy-field-as-kill t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
864 ["Paste Most Recently Killed Field" bibtex-yank t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
865 ["Paste Previously Killed Field" bibtex-yank-pop t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
866 "--" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
867 ["Make New Field" bibtex-make-field t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
868 "--" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
869 ["Snatch from Similar Following Field" bibtex-pop-next t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
870 ["Snatch from Similar Preceding Field" bibtex-pop-previous t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
871 "--" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
872 ["String or Key Complete" bibtex-complete t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
873 "--" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
874 ["Help about Current Field" bibtex-print-help-message t]) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
875 ("Operating on Buffer or Region" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
876 ["Validate Entries" bibtex-validate t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
877 ["Sort Entries" bibtex-sort-buffer t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
878 ["Reformat Entries" bibtex-reformat t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
879 ["Count Entries" bibtex-count-entries t]) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
880 ("Miscellaneous" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
881 ["Convert Alien Buffer" bibtex-convert-alien t]))) |
2602
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
882 |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
883 (easy-menu-define |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
884 bibtex-entry-menu bibtex-mode-map "Entry-Types Menu in BibTeX mode" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
885 (list "Entry-Types" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
886 ["Article in Journal" bibtex-Article t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
887 ["Article in Conference Proceedings" bibtex-InProceedings t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
888 ["Article in a Collection" bibtex-InCollection t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
889 ["Chapter or Pages in a Book" bibtex-InBook t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
890 ["Conference Proceedings" bibtex-Proceedings t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
891 ["Book" bibtex-Book t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
892 ["Booklet (Bound, but no Publisher/Institution)" bibtex-Booklet t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
893 ["PhD. Thesis" bibtex-PhdThesis t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
894 ["Master's Thesis" bibtex-MastersThesis t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
895 ["Technical Report" bibtex-TechReport t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
896 ["Technical Manual" bibtex-Manual t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
897 ["Unpublished" bibtex-Unpublished t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
898 ["Miscellaneous" bibtex-Misc t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
899 ["String" bibtex-String t] |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
900 ["Preamble" bibtex-Preamble t])) |
2602
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
901 |
14789
d68b71228abd
(bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents:
14410
diff
changeset
|
902 |
12700
b3a8ee2da96a
Add keywords and comments as per conventions.
Richard M. Stallman <rms@gnu.org>
parents:
12028
diff
changeset
|
903 ;; Internal Variables |
2602
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
904 |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
905 (defvar bibtex-pop-previous-search-point nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
906 "Next point where `bibtex-pop-previous' starts looking for a similar entry.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
907 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
908 (defvar bibtex-pop-next-search-point nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
909 "Next point where `bibtex-pop-next' starts looking for a similar entry.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
910 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
911 (defvar bibtex-field-kill-ring nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
912 "Ring of least recently killed fields. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
913 At most `bibtex-field-kill-ring-max' items are kept here.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
914 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
915 (defvar bibtex-field-kill-ring-yank-pointer nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
916 "The tail of `bibtex-field-kill-ring' whose car is the last item yanked.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
917 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
918 (defvar bibtex-entry-kill-ring nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
919 "Ring of least recently killed entries. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
920 At most `bibtex-entry-kill-ring-max' items are kept here.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
921 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
922 (defvar bibtex-entry-kill-ring-yank-pointer nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
923 "The tail of `bibtex-entry-kill-ring' whose car is the last item yanked.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
924 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
925 (defvar bibtex-last-kill-command nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
926 "Type of the last kill command (either 'field or 'entry).") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
927 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
928 (defvar bibtex-strings nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
929 "Candidates for `bibtex-complete' (string completion). |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
930 Initialized from `bibtex-predefined-strings' and `bibtex-string-files'.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
931 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
932 (defvar bibtex-reference-keys nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
933 "Candidates for TAB completion when entering a reference key using |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
934 the minibuffer. Also used for `bibtex-complete' (key completion). |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
935 Initialized in `bibtex-mode' and updated for each new entry.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
936 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
937 (defvar bibtex-buffer-last-parsed-tick nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
938 "Last value returned by `buffer-modified-tick' when buffer |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
939 was parsed for keys the last time.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
940 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
941 (defvar bibtex-parse-idle-timer nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
942 "Stores if timer is already installed.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
943 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
944 (defvar bibtex-progress-lastperc nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
945 "Last reported percentage for the progress message.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
946 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
947 (defvar bibtex-progress-lastmes nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
948 "Last reported progress message.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
949 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
950 (defvar bibtex-progress-interval nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
951 "Interval for progress messages.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
952 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
953 (defvar bibtex-key-history nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
954 "History list for reading keys.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
955 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
956 (defvar bibtex-entry-type-history nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
957 "Used to store the history list for reading entry types.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
958 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
959 (defvar bibtex-field-history nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
960 "History list for reading field names.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
961 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
962 (defvar bibtex-reformat-previous-options nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
963 "Last reformat options given.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
964 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
965 (defvar bibtex-reformat-previous-reference-keys nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
966 "Last reformat reference keys option given.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
967 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
968 (defconst bibtex-field-name "[^\"#%'(),={} \t\n0-9][^\"#%'(),={} \t\n]*" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
969 "Regexp matching the name part of a BibTeX field.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
970 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
971 (defconst bibtex-entry-type (concat "@" bibtex-field-name) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
972 "Regexp matching the type part of a BibTeX entry.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
973 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
974 (defconst bibtex-reference-key "[][a-zA-Z0-9.:;?!`'/*@+|()<>&_^$-]+" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
975 "Regexp matching the reference key part of a BibTeX entry.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
976 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
977 (defconst bibtex-field-const "[][a-zA-Z0-9.:;?!`'/*@+=|<>&_^$-]+" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
978 "Regexp matching a BibTeX field constant.") |
27701
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
979 |
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
980 (defconst bibtex-entry-head |
15637
405b1ecbf8ba
(bibtex-reference-head): Allow spaces and tabs between
Karl Heuer <kwzh@gnu.org>
parents:
15565
diff
changeset
|
981 (concat "^[ \t]*\\(" |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
982 bibtex-entry-type |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
983 "\\)[ \t]*[({][ \t\n]*\\(" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
984 bibtex-reference-key |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
985 "\\)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
986 "Regexp matching the header line of a BibTeX entry.") |
27701
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
987 |
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
988 (defconst bibtex-entry-maybe-empty-head |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
989 (concat bibtex-entry-head "?") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
990 "Regexp matching the header line of a maybe empty BibTeX entry |
51416
83476384bebd
(bibtex-member-of-regexp, bibtex-assoc-of-regexp, bibtex-format-entry)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51415
diff
changeset
|
991 \(possibly without reference key).") |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
992 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
993 (defconst bibtex-type-in-head 1 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
994 "Regexp subexpression number of the type part in `bibtex-entry-head'.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
995 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
996 (defconst bibtex-key-in-head 2 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
997 "Regexp subexpression number of the key part in `bibtex-entry-head'.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
998 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
999 (defconst bibtex-entry-postfix "[ \t\n]*,?[ \t\n]*[})]" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1000 "Regexp matching the postfix of a BibTeX entry.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1001 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1002 (defvar bibtex-known-entry-type-re |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1003 (regexp-opt (mapcar 'car bibtex-entry-field-alist)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1004 "Regexp matching the name of a BibTeX entry type.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1005 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1006 (defvar bibtex-valid-entry-re |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1007 (concat "@[ \t]*\\(" bibtex-known-entry-type-re "\\)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1008 "Regexp matching the name of a valid BibTeX entry.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1009 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1010 (defvar bibtex-valid-entry-whitespace-re |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1011 (concat "[ \t\n]*\\(" bibtex-valid-entry-re "\\)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1012 "Regexp matching the name of a valid BibTeX entry preceded by whitespace.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1013 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1014 (defvar bibtex-any-valid-entry-re |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1015 (concat "@[ \t]*" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1016 (regexp-opt (append '("String") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1017 (mapcar 'car bibtex-entry-field-alist)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1018 t)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1019 "Regexp matching the name of any valid BibTeX entry (including string).") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1020 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1021 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1022 (defconst bibtex-empty-field-re "\"\"\\|{}" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1023 "Regexp matching an empty field.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1024 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1025 (defconst bibtex-quoted-string-re |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1026 (concat "\"" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1027 "\\(" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1028 "[^\"\\]" ; anything but quote or backslash |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1029 "\\|" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1030 "\\(" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1031 "\\\\\\(.\\|\n\\)" ; any backslash quoted character |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1032 "\\)" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1033 "\\)*" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1034 "\"") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1035 "Regexp matching a field string enclosed by quotes.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1036 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1037 (defconst bibtex-font-lock-syntactic-keywords |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1038 `((,(concat "^[ \t]*\\(" (substring bibtex-comment-start 0 1) "\\)" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1039 (substring bibtex-comment-start 1) "\\>") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1040 1 '(11)))) |
2602
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
1041 |
14789
d68b71228abd
(bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents:
14410
diff
changeset
|
1042 (defvar bibtex-font-lock-keywords |
d68b71228abd
(bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents:
14410
diff
changeset
|
1043 (list |
27701
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
1044 ;; entry type and reference key |
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
1045 (list bibtex-entry-maybe-empty-head |
14789
d68b71228abd
(bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents:
14410
diff
changeset
|
1046 (list bibtex-type-in-head 'font-lock-function-name-face) |
20953
f3f9df46d008
Changed font-lock-reference-face to font-lock-constant-face.
Simon Marshall <simon@gnu.org>
parents:
20907
diff
changeset
|
1047 (list bibtex-key-in-head 'font-lock-constant-face nil t)) |
20907
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
1048 ;; optional field names (treated as comments) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1049 (list |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1050 (concat "^[ \t]*\\(OPT" bibtex-field-name "\\)[ \t]*=") |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1051 1 'font-lock-comment-face) |
20907
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
1052 ;; field names |
14789
d68b71228abd
(bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents:
14410
diff
changeset
|
1053 (list (concat "^[ \t]*\\(" bibtex-field-name "\\)[ \t]*=") |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1054 1 'font-lock-variable-name-face)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1055 "*Default expressions to highlight in BibTeX mode.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1056 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1057 (defvar bibtex-field-name-for-parsing nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1058 "Temporary variable storing the name string to be parsed by the callback |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1059 function `bibtex-parse-field-name'.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1060 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1061 (defvar bibtex-sort-entry-class-alist |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1062 (let ((i -1) alist) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1063 (dolist (class bibtex-sort-entry-class alist) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1064 (setq i (1+ i)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1065 (dolist (entry class) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1066 (push (cons entry i) alist)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1067 "Alist for the classes of the entry types if the value of |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1068 `bibtex-maintain-sorted-entries' is `entry-class'.") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1069 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1070 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1071 ;; Special support taking care of variants |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1072 (defvar zmacs-regions) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1073 (if (boundp 'mark-active) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1074 (defun bibtex-mark-active () |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1075 ;; In Emacs mark-active indicates if mark is active. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1076 mark-active) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1077 (defun bibtex-mark-active () |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1078 ;; In XEmacs (mark) returns nil when not active. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1079 (if zmacs-regions (mark) (mark t)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1080 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1081 (if (fboundp 'run-with-idle-timer) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1082 ;; timer.el is distributed with Emacs |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1083 (fset 'bibtex-run-with-idle-timer 'run-with-idle-timer) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1084 ;; timer.el is not distributed with XEmacs |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1085 ;; Notice that this does not (yet) pass the arguments, but they |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1086 ;; are not used (yet) in bibtex.el. Fix if needed. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1087 (defun bibtex-run-with-idle-timer (secs repeat function &rest args) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1088 (start-itimer "bibtex" function secs (if repeat secs nil) t))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1089 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1090 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1091 ;; Support for hideshow minor mode |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1092 (defun bibtex-hs-forward-sexp (arg) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1093 "Replacement for `forward-sexp' to be used by `hs-minor-mode'." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1094 (if (< arg 0) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1095 (backward-sexp 1) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1096 (if (looking-at "@\\S(*\\s(") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1097 (progn |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1098 (goto-char (match-end 0)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1099 (forward-char -1) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1100 (forward-sexp 1)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1101 (forward-sexp 1)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1102 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1103 (add-to-list |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1104 'hs-special-modes-alist |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1105 '(bibtex-mode "@\\S(*\\s(" "\\s)" nil bibtex-hs-forward-sexp nil)) |
27701
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
1106 |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
1107 |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1108 ;; Functions to Parse the BibTeX Entries |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1109 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1110 (defun bibtex-parse-nested-braces (nesting-level) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1111 "Starting on an opening brace, find the corresponding closing brace. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1112 When the function is called, NESTING-LEVEL has to be set to `0'." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1113 (cond ((looking-at "{") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1114 (search-forward-regexp "{[^{}]*") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1115 (bibtex-parse-nested-braces (+ nesting-level 1))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1116 ((looking-at "}") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1117 (forward-char 1) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1118 (if (= nesting-level 1) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1119 (point) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1120 (search-forward-regexp "[^{}]*") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1121 (bibtex-parse-nested-braces (- nesting-level 1)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1122 (t nil))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1123 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1124 (defun bibtex-parse-field-string () |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1125 "Parse a field string enclosed by braces or quotes. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1126 If a syntactically correct string is found, a pair containing the start and |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1127 end position of the field string is returned, nil otherwise." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1128 (save-match-data |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1129 (let ((end-point (or (and (looking-at bibtex-quoted-string-re) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1130 (match-end 0)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1131 (and (looking-at "{") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1132 (save-excursion (bibtex-parse-nested-braces 0)))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1133 (if end-point |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1134 (cons (point) end-point))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1135 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1136 (defun bibtex-parse-association (parse-lhs parse-rhs) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1137 "Parse a string of the format <left-hand-side = right-hand-side>. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1138 The functions PARSE-LHS and PARSE-RHS are used to parse the corresponding |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1139 substrings. These functions are expected to return nil if parsing is not |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1140 successfull. If both functions return non-nil, a pair containing the returned |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1141 values of the functions PARSE-LHS and PARSE-RHS is returned." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1142 (save-match-data |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1143 (save-excursion |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1144 (let (left right) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1145 (if (and (setq left (funcall parse-lhs)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1146 (looking-at "[ \t\n]*=[ \t\n]*") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1147 (goto-char (match-end 0)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1148 (setq right (funcall parse-rhs))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1149 (cons left right)))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1150 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1151 (defun bibtex-parse-field-name () |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1152 "Parse the field name stored in `bibtex-field-name-for-parsing'. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1153 If the field name is found, return a triple consisting of the position of the |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1154 very first character of the match, the actual starting position of the name |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1155 part and end position of the match. Move point to end of field name." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1156 (if (looking-at ",[ \t\n]*") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1157 (let ((start (point))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1158 (goto-char (match-end 0)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1159 (when (looking-at bibtex-field-name-for-parsing) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1160 (goto-char (match-end 0)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1161 (list start (match-beginning 0) (match-end 0)))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1162 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1163 (defun bibtex-parse-field-text () |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1164 "Parse the text part of a BibTeX field. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1165 The text part is either a string, or an empty string, or a constant followed |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1166 by one or more <# (string|constant)> pairs. If a syntactically correct text |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1167 is found, a pair containing the start and end position of the text is |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1168 returned, nil otherwise. Move point to end of field text." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1169 (let ((starting-point (point)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1170 end-point failure boundaries) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1171 (while (and (not end-point) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1172 (not failure)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1173 (cond ((looking-at bibtex-field-const) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1174 (goto-char (match-end 0))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1175 ((setq boundaries (bibtex-parse-field-string)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1176 (goto-char (cdr boundaries))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1177 ((setq failure t))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1178 (if (not (looking-at "[ \t\n]*#[ \t\n]*")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1179 (setq end-point (point)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1180 (goto-char (match-end 0)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1181 (if (and (not failure) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1182 end-point) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1183 (cons starting-point end-point)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1184 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1185 (defun bibtex-parse-field (name) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1186 "Parse a BibTeX field of regexp NAME. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1187 If a syntactically correct field is found, a pair containing the boundaries of |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1188 the name and text parts of the field is returned." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1189 (let ((bibtex-field-name-for-parsing name)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1190 (bibtex-parse-association 'bibtex-parse-field-name |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1191 'bibtex-parse-field-text))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1192 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1193 (defun bibtex-search-forward-field (name &optional bound) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1194 "Search forward to find a field of name NAME. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1195 If a syntactically correct field is found, a pair containing the boundaries of |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1196 the name and text parts of the field is returned. The search is limited by |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1197 optional arg BOUND. Do not move point." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1198 (save-match-data |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1199 (save-excursion |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1200 (unless bound (setq bound (point-max))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1201 (let ((case-fold-search t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1202 (bibtex-field-name-for-parsing name) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1203 boundaries temp-boundaries) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1204 (while (and (not boundaries) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1205 (< (point) bound) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1206 (search-forward "," bound t)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1207 (goto-char (match-beginning 0)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1208 (if (and (setq temp-boundaries |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1209 (bibtex-parse-association 'bibtex-parse-field-name |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1210 'bibtex-parse-field-text)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1211 (<= (cddr temp-boundaries) bound)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1212 (setq boundaries temp-boundaries) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1213 (forward-char 1))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1214 boundaries)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1215 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1216 (defun bibtex-search-backward-field (name &optional bound) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1217 "Search backward to find a field of name NAME. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1218 If a syntactically correct field is found, a pair containing the boundaries of |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1219 the name and text parts of the field is returned. The search is limited by |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1220 optional arg BOUND. Do not move point." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1221 (save-match-data |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1222 (save-excursion |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1223 (unless bound (setq bound (point-min))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1224 (let ((case-fold-search t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1225 (bibtex-field-name-for-parsing name) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1226 boundaries temp-boundaries) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1227 (while (and (not boundaries) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1228 (>= (point) bound) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1229 (search-backward "," bound t)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1230 (if (setq temp-boundaries |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1231 (bibtex-parse-association 'bibtex-parse-field-name |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1232 'bibtex-parse-field-text)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1233 (setq boundaries temp-boundaries))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1234 boundaries)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1235 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1236 (defun bibtex-start-of-field (bounds) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1237 (nth 0 (car bounds))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1238 (defun bibtex-start-of-name-in-field (bounds) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1239 (nth 1 (car bounds))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1240 (defun bibtex-end-of-name-in-field (bounds) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1241 (nth 2 (car bounds))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1242 (defun bibtex-end-of-field (bounds) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1243 (cddr bounds)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1244 (defun bibtex-start-of-text-in-field (bounds) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1245 (cadr bounds)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1246 (defun bibtex-end-of-text-in-field (bounds) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1247 (cddr bounds)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1248 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1249 (defun bibtex-name-in-field (bounds) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1250 "Get content of name in BibTeX field defined via BOUNDS." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1251 (buffer-substring-no-properties (nth 1 (car bounds)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1252 (nth 2 (car bounds)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1253 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1254 (defun bibtex-text-in-field-bounds (bounds &optional remove-delim) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1255 "Get content of text in BibTeX field defined via BOUNDS. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1256 If optional arg REMOVE-DELIM is non-nil remove enclosing field delimiters |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1257 if present." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1258 (let ((content (buffer-substring-no-properties (cadr bounds) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1259 (cddr bounds)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1260 (if (and remove-delim |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1261 (string-match "\\`[{\"]\\(.*\\)[}\"]\\'" content)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1262 (substring content (match-beginning 1) (match-end 1)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1263 content))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1264 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1265 (defun bibtex-text-in-field (field &optional follow-crossref) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1266 "Get content of field FIELD of current BibTeX entry. Return nil if not found. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1267 If optional arg FOLLOW-CROSSREF is non-nil, follow crossref." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1268 (save-excursion |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1269 (save-restriction |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1270 (bibtex-narrow-to-entry) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1271 (goto-char (point-min)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1272 (let ((bounds (bibtex-search-forward-field field)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1273 crossref-field) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1274 (cond (bounds (bibtex-text-in-field-bounds bounds t)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1275 ((and follow-crossref |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1276 (progn (goto-char (point-min)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1277 (setq bounds (bibtex-search-forward-field |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1278 "\\(OPT\\)?crossref")))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1279 (setq crossref-field (bibtex-text-in-field-bounds bounds t)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1280 (widen) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1281 (if (bibtex-find-crossref crossref-field) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1282 ;; Do not pass FOLLOW-CROSSREF because we want |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1283 ;; to follow crossrefs only one level of recursion. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1284 (bibtex-text-in-field field)))))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1285 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1286 (defun bibtex-parse-string-prefix () |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1287 "Parse the prefix part of a BibTeX string entry, including reference key. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1288 If the string prefix is found, return a triple consisting of the position of |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1289 the very first character of the match, the actual starting position of the |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1290 reference key and the end position of the match." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1291 (let ((case-fold-search t)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1292 (if (looking-at "^[ \t]*@string[ \t\n]*[({][ \t\n]*") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1293 (let ((start (point))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1294 (goto-char (match-end 0)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1295 (when (looking-at bibtex-reference-key) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1296 (goto-char (match-end 0)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1297 (list start |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1298 (match-beginning 0) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1299 (match-end 0))))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1300 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1301 (defun bibtex-parse-string-postfix () |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1302 "Parse the postfix part of a BibTeX string entry, including the text. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1303 If the string postfix is found, return a triple consisting of the position of |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1304 the actual starting and ending position of the text and the very last |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1305 character of the string entry. Move point past BibTeX string entry." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1306 (let* ((case-fold-search t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1307 (text-boundaries (bibtex-parse-field-text))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1308 (when text-boundaries |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1309 (goto-char (cdr text-boundaries)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1310 (when (looking-at "[ \t\n]*[})]") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1311 (goto-char (match-end 0)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1312 (list (car text-boundaries) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1313 (cdr text-boundaries) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1314 (match-end 0)))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1315 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1316 (defun bibtex-parse-string () |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1317 "Parse a BibTeX string entry. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1318 If a syntactically correct entry is found, a pair containing the boundaries of |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1319 the reference key and text parts of the entry is returned. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1320 Move point past BibTeX string entry." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1321 (bibtex-parse-association 'bibtex-parse-string-prefix |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1322 'bibtex-parse-string-postfix)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1323 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1324 (defun bibtex-search-forward-string () |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1325 "Search forward to find a BibTeX string entry. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1326 If a syntactically correct entry is found, a pair containing the boundaries of |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1327 the reference key and text parts of the string is returned. Do not move point." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1328 (save-excursion |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1329 (save-match-data |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1330 (let ((case-fold-search t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1331 boundaries) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1332 (while (and (not boundaries) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1333 (search-forward-regexp |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1334 "^[ \t]*@string[ \t\n]*[({][ \t\n]*" nil t)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1335 (goto-char (match-beginning 0)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1336 (unless (setq boundaries (bibtex-parse-string)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1337 (forward-char 1))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1338 boundaries)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1339 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1340 (defun bibtex-search-backward-string () |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1341 "Search backward to find a BibTeX string entry. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1342 If a syntactically correct entry is found, a pair containing the boundaries of |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1343 the reference key and text parts of the field is returned. Do not move point." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1344 (save-excursion |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1345 (save-match-data |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1346 (let ((case-fold-search t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1347 boundaries) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1348 (while (and (not boundaries) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1349 (search-backward-regexp |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1350 "^[ \t]*@string[ \t\n]*[({][ \t\n]*" nil t)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1351 (goto-char (match-beginning 0)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1352 (setq boundaries (bibtex-parse-string))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1353 boundaries)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1354 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1355 (defun bibtex-reference-key-in-string (bounds) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1356 (buffer-substring-no-properties (nth 1 (car bounds)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1357 (nth 2 (car bounds)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1358 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1359 (defun bibtex-text-in-string (bounds &optional remove-delim) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1360 "Get content of text in BibTeX string field defined via BOUNDS. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1361 If optional arg REMOVE-DELIM is non-nil remove enclosing field |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1362 delimiters if present." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1363 (let ((content (buffer-substring-no-properties (nth 0 (cdr bounds)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1364 (nth 1 (cdr bounds))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1365 (if (and remove-delim |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1366 (string-match "\\`{\\(.*\\)}\\'" content)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1367 (substring content (match-beginning 1) (match-end 1)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1368 content))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1369 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1370 (defun bibtex-start-of-text-in-string (bounds) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1371 (nth 0 (cdr bounds))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1372 (defun bibtex-end-of-text-in-string (bounds) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1373 (nth 1 (cdr bounds))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1374 (defun bibtex-end-of-string (bounds) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1375 (nth 2 (cdr bounds))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1376 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1377 (defun bibtex-type-in-head () |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1378 "Extract BibTeX type in head." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1379 ;; ignore @ |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1380 (buffer-substring-no-properties (1+ (match-beginning bibtex-type-in-head)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1381 (match-end bibtex-type-in-head))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1382 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1383 (defun bibtex-key-in-head (&optional empty) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1384 "Extract BibTeX key in head. Return optional arg EMPTY if key is empty." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1385 (if (match-beginning bibtex-key-in-head) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1386 (buffer-substring-no-properties (match-beginning bibtex-key-in-head) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1387 (match-end bibtex-key-in-head)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1388 empty)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1389 |
12700
b3a8ee2da96a
Add keywords and comments as per conventions.
Richard M. Stallman <rms@gnu.org>
parents:
12028
diff
changeset
|
1390 ;; Helper Functions |
2602
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
1391 |
18247
ae094c1a4334
(bibtex-delete-whitespace, bibtex-current-line)
Richard M. Stallman <rms@gnu.org>
parents:
18212
diff
changeset
|
1392 (defun bibtex-delete-whitespace () |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1393 "Delete all whitespace starting at point." |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1394 (if (looking-at "[ \t\n]+") |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1395 (delete-region (point) (match-end 0)))) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1396 |
18247
ae094c1a4334
(bibtex-delete-whitespace, bibtex-current-line)
Richard M. Stallman <rms@gnu.org>
parents:
18212
diff
changeset
|
1397 (defun bibtex-current-line () |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1398 "Compute line number of point regardless whether the buffer is narrowed." |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1399 (+ (count-lines 1 (point)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1400 (if (equal (current-column) 0) 1 0))) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1401 |
17700
d28dbbfabfb1
(assoc-ignore-case): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents:
15852
diff
changeset
|
1402 (defun bibtex-member-of-regexp (string list) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1403 "Return non-nil if STRING is exactly matched by an element of LIST. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1404 The value is actually the tail of LIST whose car matches STRING." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1405 (let (case-fold-search) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1406 (while (and list |
51416
83476384bebd
(bibtex-member-of-regexp, bibtex-assoc-of-regexp, bibtex-format-entry)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51415
diff
changeset
|
1407 (not (string-match (concat "\\`\\(?:" (car list) "\\)\\'") string))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1408 (setq list (cdr list))) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1409 list)) |
257 | 1410 |
18247
ae094c1a4334
(bibtex-delete-whitespace, bibtex-current-line)
Richard M. Stallman <rms@gnu.org>
parents:
18212
diff
changeset
|
1411 (defun bibtex-assoc-of-regexp (string alist) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1412 "Return non-nil if STRING is exactly matched by the car of an |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1413 element of ALIST (case ignored). The value is actually the element |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1414 of LIST whose car matches STRING." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1415 (let ((case-fold-search t)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1416 (while (and alist |
51416
83476384bebd
(bibtex-member-of-regexp, bibtex-assoc-of-regexp, bibtex-format-entry)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51415
diff
changeset
|
1417 (not (string-match (concat "\\`\\(?:" (caar alist) "\\)\\'") string))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1418 (setq alist (cdr alist))) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1419 (car alist))) |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
1420 |
18247
ae094c1a4334
(bibtex-delete-whitespace, bibtex-current-line)
Richard M. Stallman <rms@gnu.org>
parents:
18212
diff
changeset
|
1421 (defun bibtex-skip-to-valid-entry (&optional backward) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1422 "Unless at beginning of a valid BibTeX entry, move point to beginning of the |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1423 next valid one. With optional argument BACKWARD non-nil, move backward to |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1424 beginning of previous valid one. A valid entry is a syntactical correct one |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1425 with type contained in `bibtex-entry-field-alist' or, if |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1426 `bibtex-sort-ignore-string-entries' is nil, a syntactical correct string |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1427 entry. Return buffer position if a valid entry is found, nil otherwise." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1428 (let ((case-fold-search t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1429 found) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1430 (while (and (not found) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1431 (not (if backward (bobp) (eobp)))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1432 (let ((pnt (point))) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1433 (cond ((or (and (looking-at bibtex-valid-entry-re) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1434 (bibtex-search-entry nil nil t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1435 (equal (match-beginning 0) pnt)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1436 (and (not bibtex-sort-ignore-string-entries) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1437 (bibtex-parse-string))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1438 (setq found pnt) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1439 (goto-char pnt)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1440 (backward |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1441 (goto-char (1- pnt)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1442 (if (re-search-backward "^[ \t]*\\(@\\)" nil 'move) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1443 (goto-char (match-beginning 1)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1444 (t (goto-char (1+ pnt)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1445 (if (re-search-forward "^[ \t]*@" nil 'move) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1446 (forward-char -1)))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1447 found)) |
2602
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
1448 |
18247
ae094c1a4334
(bibtex-delete-whitespace, bibtex-current-line)
Richard M. Stallman <rms@gnu.org>
parents:
18212
diff
changeset
|
1449 (defun bibtex-map-entries (fun) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1450 "Call FUN for each BibTeX entry starting with the current. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1451 Do this to the end of the file. FUN is called with one argument, the key |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1452 of the entry, and with point inside the entry. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1453 If `bibtex-sort-ignore-string-entries' is non-nil, FUN will not be |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1454 called for @String entries." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1455 (let ((case-fold-search t)) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1456 (bibtex-beginning-of-entry) |
27701
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
1457 (while (re-search-forward bibtex-entry-maybe-empty-head nil t) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1458 (save-excursion |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1459 (let ((entry-type (downcase (bibtex-type-in-head))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1460 (key (bibtex-key-in-head ""))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1461 (if (or (and (not bibtex-sort-ignore-string-entries) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1462 (string-equal "string" entry-type)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1463 (assoc-ignore-case entry-type bibtex-entry-field-alist)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1464 (funcall fun key)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1465 (bibtex-end-of-entry)))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1466 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1467 (defun bibtex-progress-message (&optional flag interval) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1468 "Echo a message about progress of current buffer. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1469 If FLAG is a string, the message is initialized (in this case a |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1470 value for INTERVAL may be given as well (if not this is set to 5)). |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1471 If FLAG is done, the message is deinitialized. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1472 If FLAG is absent, a message is echoed if point was incremented |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1473 at least INTERVAL percent since last message was echoed." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1474 (cond ((stringp flag) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1475 (setq bibtex-progress-lastmes flag) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1476 (setq bibtex-progress-interval (or interval 5) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1477 bibtex-progress-lastperc 0)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1478 ((equal flag 'done) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1479 (message "%s (done)" bibtex-progress-lastmes) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1480 (setq bibtex-progress-lastmes nil)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1481 (t |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1482 (let* ((size (- (point-max) (point-min))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1483 (perc (if (= size 0) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1484 100 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1485 (/ (* 100 (- (point) (point-min))) size)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1486 (when (>= perc (+ bibtex-progress-lastperc |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1487 bibtex-progress-interval)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1488 (setq bibtex-progress-lastperc perc) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1489 (message "%s (%d%%)" bibtex-progress-lastmes perc)))))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1490 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1491 (defun bibtex-field-left-delimiter () |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1492 "Return a string dependent on `bibtex-field-delimiters'." |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1493 (if (equal bibtex-field-delimiters 'braces) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1494 "{" |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1495 "\"")) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1496 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1497 (defun bibtex-field-right-delimiter () |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1498 "Return a string dependent on `bibtex-field-delimiters'." |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1499 (if (equal bibtex-field-delimiters 'braces) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1500 "}" |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1501 "\"")) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1502 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1503 (defun bibtex-entry-left-delimiter () |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1504 "Return a string dependent on `bibtex-field-delimiters'." |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1505 (if (equal bibtex-entry-delimiters 'braces) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1506 "{" |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1507 "(")) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1508 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1509 (defun bibtex-entry-right-delimiter () |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1510 "Return a string dependent on `bibtex-field-delimiters'." |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1511 (if (equal bibtex-entry-delimiters 'braces) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1512 "}" |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1513 ")")) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1514 |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1515 (defun bibtex-search-entry (empty-head &optional bound noerror backward) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1516 "A helper function necessary since the failure stack size limit for |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1517 regexps was reduced in emacs 19.32. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1518 It searches for a BibTeX entry (maybe without a reference key if |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1519 EMPTY-HEAD is t). |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1520 BOUND and NOERROR are exactly as in `re-search-forward'. If |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1521 BACKWARD is non-nil, search is done in reverse direction. After |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1522 call to this function MATCH-BEGINNING and MATCH-END functions are |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1523 defined, but only for the head part of the entry (especially |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1524 \(match-end 0) just gives the end of the head part)." |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1525 (let ((pnt (point)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1526 (prefix (if empty-head |
27701
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
1527 bibtex-entry-maybe-empty-head |
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
1528 bibtex-entry-head))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1529 (if backward |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1530 (let (found) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1531 (while (and (not found) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1532 (re-search-backward prefix bound noerror)) |
27701
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
1533 (setq found (bibtex-search-entry empty-head pnt t))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1534 (if found |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1535 (goto-char (match-beginning 0)) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1536 (cond ((equal noerror nil) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1537 ;; yell |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1538 (error "Search of BibTeX entry failed")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1539 ((equal noerror t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1540 ;; don't move |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1541 (goto-char pnt))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1542 nil)) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1543 (let ((limit (or bound (point-max))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1544 found) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1545 (while (and (not found) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1546 (re-search-forward prefix bound noerror)) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1547 (save-match-data |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1548 (let ((entry-closer |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1549 (if (save-excursion |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1550 (goto-char (match-end bibtex-type-in-head)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1551 (looking-at "[ \t]*(")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1552 ;; entry opened with parenthesis |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1553 ?\) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1554 ?\})) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1555 (infix-start (point)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1556 finished bounds) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1557 (while (not finished) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1558 (skip-chars-forward " \t\n" limit) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1559 (if (and (setq bounds (bibtex-parse-field bibtex-field-name)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1560 (<= (bibtex-end-of-field bounds) limit)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1561 (setq infix-start (bibtex-end-of-field bounds)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1562 (setq finished t)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1563 (goto-char infix-start)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1564 ;; This matches the infix* part. The AND construction assures |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1565 ;; that BOUND is respected. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1566 (when (and (looking-at bibtex-entry-postfix) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1567 (eq (char-before (match-end 0)) entry-closer) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1568 (<= (match-end 0) limit)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1569 (goto-char (match-end 0)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1570 (setq found t))))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1571 (if found |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1572 (point) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1573 (cond ((not noerror) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1574 ;; yell |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1575 (error "Search of BibTeX entry failed")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1576 ((equal noerror t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1577 ;; don't move |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1578 (goto-char pnt))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1579 nil))))) |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
1580 |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
1581 (defun bibtex-flash-head () |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1582 "Flash at BibTeX entry head before point, if exists." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1583 (let ((case-fold-search t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1584 flash) |
27701
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
1585 (cond ((re-search-backward bibtex-entry-head nil t) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1586 (goto-char (match-beginning bibtex-type-in-head)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1587 (setq flash (match-end bibtex-key-in-head))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1588 (t |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1589 (end-of-line) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1590 (skip-chars-backward " \t") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1591 (setq flash (point)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1592 (beginning-of-line) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1593 (skip-chars-forward " \t"))) |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
1594 (if (pos-visible-in-window-p (point)) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1595 (sit-for 1) |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
1596 (message "From: %s" |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1597 (buffer-substring (point) flash))))) |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
1598 |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1599 (defun bibtex-make-optional-field (e-t) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1600 "Make an optional field named E-T in current BibTeX entry." |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1601 (if (consp e-t) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1602 (bibtex-make-field (cons (concat "OPT" (car e-t)) (cdr e-t))) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1603 (bibtex-make-field (concat "OPT" e-t)))) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1604 |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
1605 (defun bibtex-move-outside-of-entry () |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1606 "Make sure point is outside of a BibTeX entry." |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
1607 (let ((orig-point (point))) |
26711
eac840d283b6
(bibtex-hs-forward-sexp): Added to support
Gerd Moellmann <gerd@gnu.org>
parents:
25444
diff
changeset
|
1608 (bibtex-end-of-entry) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1609 (when (<= (point) orig-point) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1610 ;; We moved backward, so we weren't inside an entry to begin with. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1611 ;; Leave point at the beginning of a line, and preferably |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1612 ;; at the beginning of a paragraph. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1613 (goto-char orig-point) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1614 (beginning-of-line 1) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1615 (let ((cb (char-before (1- (point))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1616 (unless (and cb (= ?\n cb)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1617 (re-search-forward "^[ \t]*[@\n]" nil 'move) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1618 (backward-char 1)))) |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
1619 (skip-chars-forward " \t\n"))) |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
1620 |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1621 (defun bibtex-beginning-of-first-entry () |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1622 "Go to the beginning of the first BibTeX entry in buffer. Return point." |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
1623 (goto-char (point-min)) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1624 (if (re-search-forward "^[ \t]*@" nil 'move) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1625 (beginning-of-line)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1626 (point)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1627 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1628 (defun bibtex-beginning-of-last-entry () |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1629 "Go to the beginning of the last BibTeX entry in buffer." |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1630 (goto-char (point-max)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1631 (if (re-search-backward "^[ \t]*@" nil 'move) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1632 (beginning-of-line)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1633 (point)) |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
1634 |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
1635 (defun bibtex-inside-field () |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1636 "Try to avoid point being at end of a BibTeX field." |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
1637 (end-of-line) |
13728
4b7903cfa7ee
(bibtex-auto-fill-function): Adapted for use with
Karl Heuer <kwzh@gnu.org>
parents:
12770
diff
changeset
|
1638 (skip-chars-backward " \t") |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
1639 (cond ((= (preceding-char) ?,) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1640 (forward-char -2))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1641 (cond ((or (= (preceding-char) ?}) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1642 (= (preceding-char) ?\")) |
13728
4b7903cfa7ee
(bibtex-auto-fill-function): Adapted for use with
Karl Heuer <kwzh@gnu.org>
parents:
12770
diff
changeset
|
1643 (forward-char -1)))) |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
1644 |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1645 (defun bibtex-enclosing-field (&optional noerr) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1646 "Search for BibTeX field enclosing point. Point moves to end of field. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1647 Use `match-beginning' and `match-end' to parse the field. If NOERR is non-nil, |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1648 no error is signalled. In this case, bounds are returned on success, |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1649 nil otherwise." |
27701
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
1650 (let* ((case-fold-search t) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1651 (old-point (point)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1652 (boe (save-excursion (bibtex-beginning-of-entry))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1653 (bounds (bibtex-search-backward-field bibtex-field-name boe))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1654 (if (and bounds |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1655 (<= (bibtex-start-of-field bounds) old-point) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1656 (>= (bibtex-end-of-field bounds) old-point)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1657 bounds |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1658 (unless noerr |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1659 (error "Can't find enclosing BibTeX field"))))) |
27701
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
1660 |
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
1661 (defun bibtex-enclosing-entry-maybe-empty-head () |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1662 "Search for BibTeX entry enclosing point. Point moves to end of entry. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1663 Beginning (but not end) of entry is given by (`match-beginning' 0)." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1664 (let ((case-fold-search t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1665 (old-point (point))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1666 (unless (re-search-backward bibtex-entry-maybe-empty-head nil t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1667 (error "Can't find enclosing BibTeX entry") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1668 (goto-char old-point)) |
13728
4b7903cfa7ee
(bibtex-auto-fill-function): Adapted for use with
Karl Heuer <kwzh@gnu.org>
parents:
12770
diff
changeset
|
1669 (goto-char (match-beginning bibtex-type-in-head)) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1670 (unless (bibtex-search-entry t nil t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1671 (error "Can't find enclosing BibTeX entry") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1672 (goto-char old-point)))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1673 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1674 (defun bibtex-insert-current-kill (n) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1675 (if (not bibtex-last-kill-command) |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
1676 (error "BibTeX kill ring is empty") |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1677 (let* ((kr (if (equal bibtex-last-kill-command 'field) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1678 'bibtex-field-kill-ring |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1679 'bibtex-entry-kill-ring)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1680 (kryp (if (equal bibtex-last-kill-command 'field) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1681 'bibtex-field-kill-ring-yank-pointer |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1682 'bibtex-entry-kill-ring-yank-pointer)) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1683 (ARGth-kill-element (nthcdr (mod (- n (length (eval kryp))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1684 (length (eval kr))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1685 (eval kr))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1686 (current (car (set kryp ARGth-kill-element)))) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1687 (cond |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1688 ((equal bibtex-last-kill-command 'field) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1689 (let (bibtex-help-message) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1690 (bibtex-find-text nil t) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1691 (if (looking-at "[}\"]") |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1692 (forward-char))) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1693 (set-mark (point)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1694 (message "Mark set") |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1695 (bibtex-make-field (list (elt current 1) nil (elt current 2)) t)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1696 ((equal bibtex-last-kill-command 'entry) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1697 (if (not (eobp)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1698 (bibtex-beginning-of-entry)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1699 (set-mark (point)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1700 (message "Mark set") |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1701 (insert (elt current 1))) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1702 (t |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1703 (error "Unknown tag field: %s. Please submit a bug report" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1704 bibtex-last-kill-command)))))) |
27701
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
1705 |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1706 (defun bibtex-format-entry () |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1707 "Helper function for `bibtex-clean-entry'. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1708 Formats current entry according to variable `bibtex-entry-format'." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1709 (save-excursion |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1710 (save-restriction |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1711 (bibtex-narrow-to-entry) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1712 (let ((case-fold-search t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1713 (format (if (equal bibtex-entry-format t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1714 '(realign opts-or-alts required-fields |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1715 numerical-fields |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1716 last-comma page-dashes delimiters |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1717 unify-case inherit-booktitle) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1718 bibtex-entry-format)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1719 crossref-key bounds alternatives-there non-empty-alternative |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1720 entry-list req creq field-done field-list) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1721 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1722 ;; identify entry type |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1723 (goto-char (point-min)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1724 (re-search-forward bibtex-entry-type) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1725 (let ((beg-type (1+ (match-beginning 0))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1726 (end-type (match-end 0))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1727 (setq entry-list (assoc-ignore-case (buffer-substring-no-properties |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1728 beg-type end-type) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1729 bibtex-entry-field-alist) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1730 req (nth 0 (nth 1 entry-list)) ; required part |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1731 creq (nth 0 (nth 2 entry-list))) ; crossref part |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1732 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1733 ;; unify case of entry name |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1734 (when (memq 'unify-case format) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1735 (delete-region beg-type end-type) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1736 (insert (car entry-list))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1737 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1738 ;; update left entry delimiter |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1739 (when (memq 'delimiters format) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1740 (goto-char end-type) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1741 (skip-chars-forward " \t\n") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1742 (delete-char 1) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1743 (insert (bibtex-entry-left-delimiter)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1744 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1745 ;; determine if entry has crossref field and if at least |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1746 ;; one alternative is non-empty |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1747 (goto-char (point-min)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1748 (while (setq bounds (bibtex-search-forward-field |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1749 bibtex-field-name)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1750 (goto-char (bibtex-start-of-name-in-field bounds)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1751 (cond ((looking-at "ALT") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1752 (setq alternatives-there t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1753 (goto-char (bibtex-start-of-text-in-field bounds)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1754 (if (not (looking-at bibtex-empty-field-re)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1755 (setq non-empty-alternative t))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1756 ((and (looking-at "\\(OPT\\)?crossref\\>") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1757 (progn (goto-char (bibtex-start-of-text-in-field bounds)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1758 (not (looking-at bibtex-empty-field-re)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1759 (setq crossref-key |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1760 (bibtex-text-in-field-bounds bounds t)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1761 (goto-char (bibtex-end-of-field bounds))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1762 (if (and alternatives-there |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1763 (not non-empty-alternative) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1764 (memq 'required-fields format)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1765 (error "All alternatives are empty")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1766 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1767 ;; process all fields |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1768 (goto-char (point-min)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1769 (while (setq bounds (bibtex-search-forward-field bibtex-field-name)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1770 (let* ((beg-field (copy-marker (bibtex-start-of-field bounds))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1771 (end-field (copy-marker (bibtex-end-of-field bounds))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1772 (beg-name (copy-marker (bibtex-start-of-name-in-field bounds))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1773 (end-name (copy-marker (bibtex-end-of-name-in-field bounds))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1774 (beg-text (copy-marker (bibtex-start-of-text-in-field bounds))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1775 (end-text (copy-marker (bibtex-end-of-text-in-field bounds))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1776 (opt-alt (string-match "OPT\\|ALT" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1777 (buffer-substring-no-properties beg-name (+ beg-name 3)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1778 (field-name (buffer-substring-no-properties |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1779 (if opt-alt (+ beg-name 3) beg-name) end-name)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1780 (empty-field (string-match bibtex-empty-field-re |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1781 (buffer-substring-no-properties beg-field end-field))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1782 deleted) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1783 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1784 ;; We have more elegant high-level functions for several |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1785 ;; tasks done by bibtex-format-entry. However, they contain |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1786 ;; quite some redundancy compared with what we need to do |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1787 ;; anyway. So for speed-up we avoid using them. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1788 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1789 (when (and opt-alt |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1790 (memq 'opts-or-alts format)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1791 (if empty-field |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1792 ;; Either it is an empty ALT field. Then we have checked |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1793 ;; already that we have one non-empty alternative. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1794 ;; Or it is an empty OPT field that we do not miss anyway. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1795 ;; So we can safely delete this field. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1796 (progn (delete-region beg-field end-field) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1797 (setq deleted t)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1798 ;; otherwise: not empty, delete "OPT" or "ALT" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1799 (goto-char beg-name) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1800 (delete-char 3))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1801 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1802 (unless deleted |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1803 (push field-name field-list) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1804 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1805 ;; remove delimiters from purely numerical fields |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1806 (when (and (memq 'numerical-fields format) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1807 (progn (goto-char beg-text) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1808 (looking-at "\\(\"[0-9]+\"\\)\\|\\({[0-9]+}\\)"))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1809 (goto-char end-text) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1810 (delete-char -1) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1811 (goto-char beg-text) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1812 (delete-char 1)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1813 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1814 ;; update delimiters |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1815 (when (memq 'delimiters format) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1816 (goto-char beg-text) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1817 (when (looking-at "[{\"]") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1818 (delete-char 1) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1819 (insert (bibtex-field-left-delimiter))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1820 (goto-char (1- (marker-position end-text))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1821 (when (looking-at "[}\"]") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1822 (delete-char 1) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1823 (insert (bibtex-field-right-delimiter)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1824 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1825 ;; update page dashes |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1826 (if (and (memq 'page-dashes format) |
51416
83476384bebd
(bibtex-member-of-regexp, bibtex-assoc-of-regexp, bibtex-format-entry)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51415
diff
changeset
|
1827 (string-match "\\`\\(OPT\\)?pages\\'" field-name) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1828 (progn (goto-char beg-text) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1829 (looking-at |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1830 "\\([\"{][0-9]+\\)[ \t\n]*--?[ \t\n]*\\([0-9]+[\"}]\\)"))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1831 (replace-match "\\1-\\2")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1832 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1833 ;; use book title of crossrefed entry |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1834 (if (and (memq 'inherit-booktitle format) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1835 (equal (downcase field-name) "booktitle") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1836 empty-field |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1837 crossref-key) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1838 (let ((title (save-restriction |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1839 (widen) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1840 (if (bibtex-find-entry crossref-key) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1841 (bibtex-text-in-field "title"))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1842 (when title |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1843 (setq empty-field nil) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1844 (goto-char (1+ beg-text)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1845 (insert title)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1846 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1847 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1848 ;; if empty field, complain |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1849 (if (and empty-field |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1850 (memq 'required-fields format) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1851 (assoc-ignore-case field-name |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1852 (if crossref-key creq req))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1853 (error "Mandatory field `%s' is empty" field-name)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1854 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1855 ;; unify case of field name |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1856 (if (memq 'unify-case format) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1857 (let ((fname (car (assoc-ignore-case |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1858 field-name (append (nth 0 (nth 1 entry-list)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1859 (nth 1 (nth 1 entry-list)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1860 bibtex-user-optional-fields))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1861 (if fname |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1862 (progn |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1863 (delete-region beg-name end-name) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1864 (goto-char beg-name) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1865 (insert fname)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1866 ;; there are no rules we could follow |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1867 (downcase-region beg-name end-name)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1868 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1869 ;; update point |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1870 (goto-char end-field)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1871 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1872 ;; check whether all required fields are present |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1873 (if (memq 'required-fields format) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1874 (let (altlist (found 0)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1875 (dolist (fname (if crossref-key creq req)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1876 (if (nth 3 fname) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1877 (push (car fname) altlist)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1878 (unless (or (member (car fname) field-list) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1879 (nth 3 fname)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1880 (error "Mandatory field `%s' is missing" (car fname)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1881 (when altlist |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1882 (dolist (fname altlist) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1883 (if (member fname field-list) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1884 (setq found (1+ found)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1885 (cond ((= found 0) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1886 (error "Alternative mandatory field `%s' is missing" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1887 altlist)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1888 ((> found 1) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1889 (error "Alternative fields `%s' is defined %s times" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1890 altlist found)))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1891 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1892 ;; update point |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1893 (if (looking-at (bibtex-field-right-delimiter)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1894 (forward-char)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1895 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1896 ;; update comma after last field |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1897 (if (memq 'last-comma format) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1898 (cond ((and bibtex-comma-after-last-field |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1899 (not (looking-at ","))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1900 (insert ",")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1901 ((and (not bibtex-comma-after-last-field) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1902 (looking-at ",")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1903 (delete-char 1)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1904 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1905 ;; update right entry delimiter |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1906 (if (looking-at ",") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1907 (forward-char)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1908 (when (memq 'delimiters format) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1909 (skip-chars-forward " \t\n") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1910 (delete-char 1) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1911 (insert (bibtex-entry-right-delimiter))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1912 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1913 ;; fill entry |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1914 (if (memq 'realign format) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1915 (bibtex-fill-entry)))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1916 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1917 |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
1918 (defun bibtex-autokey-abbrev (string len) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1919 "Return an abbreviation of STRING with at least LEN characters. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1920 If LEN is positive the abbreviation is terminated only after a consonant |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1921 or at the word end. If LEN is negative the abbreviation is strictly |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1922 enforced using abs (LEN) characters. If LEN is not a number, STRING |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1923 is returned unchanged." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1924 (cond ((or (not (numberp len)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1925 (<= (length string) (abs len))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1926 string) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1927 ((equal len 0) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1928 "") |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1929 ((< len 0) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1930 (substring string 0 (abs len))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1931 (t (let* ((case-fold-search t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1932 (abort-char (string-match "[^aeiou]" string (1- len)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1933 (if abort-char |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1934 (substring string 0 (1+ abort-char)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1935 string))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1936 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1937 (defun bibtex-autokey-get-field (field &optional change-list) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1938 "Get content of BibTeX field FIELD. Return empty string if not found. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1939 Optional arg CHANGE-LIST is a list of substitution patterns that is |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1940 applied to the content of FIELD. It is an alist with pairs |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1941 \(OLD-REGEXP . NEW-STRING\)." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1942 (let ((content (bibtex-text-in-field field bibtex-autokey-use-crossref)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1943 case-fold-search) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1944 (unless content (setq content "")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1945 (dolist (pattern change-list content) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1946 (setq content (replace-regexp-in-string (car pattern) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1947 (cdr pattern) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1948 content))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1949 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1950 (defun bibtex-autokey-get-names () |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1951 "Get contents of the name field of the current entry. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1952 Do some modifications based on `bibtex-autokey-name-change-strings' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1953 and return results as a list." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1954 (let ((case-fold-search t)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1955 (mapcar 'bibtex-autokey-demangle-name |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1956 (split-string (bibtex-autokey-get-field |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1957 "\\(author\\)\\|\\(editor\\)" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1958 bibtex-autokey-name-change-strings) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1959 "[ ]+and[ ]+")))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1960 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1961 (defun bibtex-autokey-demangle-name (fullname) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1962 "Get the last part from a well-formed name and perform abbreviations." |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
1963 (let* (case-fold-search |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1964 (name (cond ((string-match "\\([A-Z][^, ]*\\)[^,]*," fullname) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1965 ;; Name is of the form "von Last, First" or |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1966 ;; "von Last, Jr, First" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1967 ;; --> Take the first capital part before the comma |
51416
83476384bebd
(bibtex-member-of-regexp, bibtex-assoc-of-regexp, bibtex-format-entry)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51415
diff
changeset
|
1968 (match-string 1 fullname)) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1969 ((string-match "\\([^, ]*\\)," fullname) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1970 ;; Strange name: we have a comma, but nothing capital |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1971 ;; So we accept even lowercase names |
51416
83476384bebd
(bibtex-member-of-regexp, bibtex-assoc-of-regexp, bibtex-format-entry)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51415
diff
changeset
|
1972 (match-string 1 fullname)) |
83476384bebd
(bibtex-member-of-regexp, bibtex-assoc-of-regexp, bibtex-format-entry)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51415
diff
changeset
|
1973 ((string-match "\\(\\<[a-z][^ ]* +\\)+\\([A-Z][^ ]*\\)" |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1974 fullname) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1975 ;; name is of the form "First von Last", "von Last", |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1976 ;; "First von von Last", or "d'Last" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1977 ;; --> take the first capital part after the "von" parts |
51416
83476384bebd
(bibtex-member-of-regexp, bibtex-assoc-of-regexp, bibtex-format-entry)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51415
diff
changeset
|
1978 (match-string 2 fullname)) |
83476384bebd
(bibtex-member-of-regexp, bibtex-assoc-of-regexp, bibtex-format-entry)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51415
diff
changeset
|
1979 ((string-match "\\([^ ]+\\) *\\'" fullname) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1980 ;; name is of the form "First Middle Last" or "Last" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1981 ;; --> take the last token |
51416
83476384bebd
(bibtex-member-of-regexp, bibtex-assoc-of-regexp, bibtex-format-entry)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51415
diff
changeset
|
1982 (match-string 1 fullname)) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1983 (t (error "Name `%s' is incorrectly formed" fullname))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1984 (bibtex-autokey-abbrev |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1985 (funcall bibtex-autokey-name-case-convert name) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1986 bibtex-autokey-name-length))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1987 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1988 (defun bibtex-autokey-get-title () |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1989 "Get title field contents up to a terminator." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1990 (let ((titlestring |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1991 (bibtex-autokey-get-field "title" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1992 bibtex-autokey-titleword-change-strings))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1993 ;; ignore everything past a terminator |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1994 (let ((case-fold-search t)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1995 (dolist (terminator bibtex-autokey-title-terminators) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1996 (if (string-match terminator titlestring) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1997 (setq titlestring (substring titlestring 0 (match-beginning 0)))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1998 ;; gather words from titlestring into a list. Ignore |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
1999 ;; specific words and use only a specific amount of words. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2000 (let (case-fold-search titlewords titlewords-extra titleword end-match |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2001 (counter 0)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2002 (while (and (or (not (numberp bibtex-autokey-titlewords)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2003 (< counter (+ bibtex-autokey-titlewords |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2004 bibtex-autokey-titlewords-stretch))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2005 (string-match "\\b\\w+" titlestring)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2006 (setq end-match (match-end 0) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2007 titleword (substring titlestring |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2008 (match-beginning 0) end-match)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2009 (unless (bibtex-member-of-regexp titleword |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2010 bibtex-autokey-titleword-ignore) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2011 (setq titleword |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2012 (funcall bibtex-autokey-titleword-case-convert titleword)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2013 (if (or (not (numberp bibtex-autokey-titlewords)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2014 (< counter bibtex-autokey-titlewords)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2015 (setq titlewords (append titlewords (list titleword))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2016 (setq titlewords-extra |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2017 (append titlewords-extra (list titleword)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2018 (setq counter (1+ counter))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2019 (setq titlestring (substring titlestring end-match))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2020 (unless (string-match "\\b\\w+" titlestring) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2021 (setq titlewords (append titlewords titlewords-extra))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2022 (mapcar 'bibtex-autokey-demangle-title titlewords)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2023 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2024 (defun bibtex-autokey-demangle-title (titleword) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2025 "Do some abbreviations on TITLEWORD. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2026 The rules are defined in `bibtex-autokey-titleword-abbrevs' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2027 and `bibtex-autokey-titleword-length'." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2028 (let ((abbrev (bibtex-assoc-of-regexp |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2029 titleword bibtex-autokey-titleword-abbrevs))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2030 (if abbrev |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2031 (cdr abbrev) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2032 (bibtex-autokey-abbrev titleword |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2033 bibtex-autokey-titleword-length)))) |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
2034 |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
2035 (defun bibtex-generate-autokey () |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2036 "Generate automatically a key from the author/editor and the title field. |
20446
4bcd559e2cb4
(bibtex-generate-autokey): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
20359
diff
changeset
|
2037 This will only work for entries where each field begins on a separate line. |
4bcd559e2cb4
(bibtex-generate-autokey): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
20359
diff
changeset
|
2038 The generation algorithm works as follows: |
4bcd559e2cb4
(bibtex-generate-autokey): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
20359
diff
changeset
|
2039 1. Use the value of `bibtex-autokey-prefix-string' as a prefix. |
4bcd559e2cb4
(bibtex-generate-autokey): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
20359
diff
changeset
|
2040 2. If there is a non-empty author (preferred) or editor field, |
4bcd559e2cb4
(bibtex-generate-autokey): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
20359
diff
changeset
|
2041 use it as the name part of the key. |
20907
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2042 3. Change any substring found in |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2043 `bibtex-autokey-name-change-strings' to the corresponding new |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2044 one (see documentation of this variable for further detail). |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2045 4. For every of at least first `bibtex-autokey-names' names in |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2046 the name field, determine the last name. If there are maximal |
20446
4bcd559e2cb4
(bibtex-generate-autokey): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
20359
diff
changeset
|
2047 `bibtex-autokey-names' + `bibtex-autokey-names-stretch' |
4bcd559e2cb4
(bibtex-generate-autokey): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
20359
diff
changeset
|
2048 names, all names are used. |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2049 5. From every last name, take at least `bibtex-autokey-name-length' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2050 characters (abort only after a consonant or at a word end). |
20907
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2051 6. Convert all last names according to the conversion function |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2052 `bibtex-autokey-name-case-convert'. |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2053 7. Build the name part of the key by concatenating all |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2054 abbreviated last names with the string |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2055 `bibtex-autokey-name-separator' between any two. If there are |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2056 more names than are used in the name part, prepend the string |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2057 contained in `bibtex-autokey-additional-names'. |
20446
4bcd559e2cb4
(bibtex-generate-autokey): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
20359
diff
changeset
|
2058 8. Build the year part of the key by truncating the contents of |
4bcd559e2cb4
(bibtex-generate-autokey): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
20359
diff
changeset
|
2059 the year field to the rightmost `bibtex-autokey-year-length' |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2060 digits (useful values are 2 and 4). If the year field (or any |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2061 other field required to generate the key) is absent, but the entry |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2062 has a valid crossref field and the variable |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2063 `bibtex-autokey-use-crossref' is non-nil, use the field of the |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2064 crossreferenced entry instead. |
20907
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2065 9. For the title part of the key change the contents of the |
27701
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
2066 title field of the entry according to |
20907
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2067 `bibtex-autokey-titleword-change-strings' to the |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2068 corresponding new one (see documentation of this variable for |
20446
4bcd559e2cb4
(bibtex-generate-autokey): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
20359
diff
changeset
|
2069 further detail). |
4bcd559e2cb4
(bibtex-generate-autokey): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
20359
diff
changeset
|
2070 10. Abbreviate the result to the string up to (but not including) |
4bcd559e2cb4
(bibtex-generate-autokey): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
20359
diff
changeset
|
2071 the first occurrence of a regexp matched by the items of |
20907
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2072 `bibtex-autokey-title-terminators' and delete those words which |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2073 appear in `bibtex-autokey-titleword-ignore'. |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2074 Build the title part of the key by using at least the first |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2075 `bibtex-autokey-titlewords' words from this |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2076 abbreviated title. If the abbreviated title ends after |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2077 maximal `bibtex-autokey-titlewords' + |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2078 `bibtex-autokey-titlewords-stretch' words, all |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2079 words from the abbreviated title are used. |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2080 11. Convert all used titlewords according to the conversion function |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2081 `bibtex-autokey-titleword-case-convert'. |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2082 12. For every used title word that appears in |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2083 `bibtex-autokey-titleword-abbrevs' use the corresponding |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2084 abbreviation (see documentation of this variable for further |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2085 detail). |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2086 13. From every title word not generated by an abbreviation, take |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2087 at least `bibtex-autokey-titleword-length' characters (abort |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2088 only after a consonant or at a word end). |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2089 14. Build the title part of the key by concatenating all |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2090 abbreviated title words with the string |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2091 `bibtex-autokey-titleword-separator' between any two. |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2092 15. At least, to get the key, concatenate |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2093 `bibtex-autokey-prefix-string', the name part, the year part |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2094 and the title part with `bibtex-autokey-name-year-separator' |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2095 between the name part and the year part if both are non-empty |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2096 and `bibtex-autokey-year-title-separator' between the year |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2097 part and the title part if both are non-empty. If the year |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2098 part is empty, but not the other two parts, |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2099 `bibtex-autokey-year-title-separator' is used as well. |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2100 16. If the value of `bibtex-autokey-before-presentation-function' |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2101 is non-nil, it must be a function taking one argument. This |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2102 function is then called with the generated key as the |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2103 argument. The return value of this function (a string) is |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2104 used as the key. |
20446
4bcd559e2cb4
(bibtex-generate-autokey): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
20359
diff
changeset
|
2105 17. If the value of `bibtex-autokey-edit-before-use' is non-nil, |
20907
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2106 the key is then presented in the minibuffer to the user, |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
2107 where it can be edited. The key given by the user is then |
20907
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2108 used." |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2109 (let* ((name-etal "") |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
2110 (namelist |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2111 (let ((nl (bibtex-autokey-get-names)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2112 nnl) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2113 (if (or (not (numberp bibtex-autokey-names)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2114 (<= (length nl) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2115 (+ bibtex-autokey-names |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2116 bibtex-autokey-names-stretch))) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2117 nl |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2118 (setq name-etal bibtex-autokey-additional-names) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2119 (while (< (length nnl) bibtex-autokey-names) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2120 (setq nnl (append nnl (list (car nl))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2121 nl (cdr nl))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2122 nnl))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2123 (namepart (concat (mapconcat (lambda (name) name) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2124 namelist |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2125 bibtex-autokey-name-separator) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2126 name-etal)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2127 (yearfield (bibtex-autokey-get-field "year")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2128 (yearpart (if (equal yearfield "") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2129 "" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2130 (substring yearfield |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2131 (- (length yearfield) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2132 bibtex-autokey-year-length)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2133 (titlepart (mapconcat (lambda (name) name) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2134 (bibtex-autokey-get-title) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2135 bibtex-autokey-titleword-separator)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2136 (autokey (concat bibtex-autokey-prefix-string |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2137 namepart |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2138 (unless (or (equal namepart "") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2139 (equal yearpart "")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2140 bibtex-autokey-name-year-separator) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2141 yearpart |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2142 (unless (or (and (equal namepart "") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2143 (equal yearpart "")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2144 (equal titlepart "")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2145 bibtex-autokey-year-title-separator) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2146 titlepart))) |
20907
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2147 (if bibtex-autokey-before-presentation-function |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2148 (funcall bibtex-autokey-before-presentation-function autokey) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2149 autokey))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2150 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2151 |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2152 (defun bibtex-parse-keys (add verbose &optional abortable) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2153 "Set `bibtex-reference-keys' to the keys used in the whole buffer. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2154 The buffer might possibly be restricted. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2155 Find both entry keys and crossref entries. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2156 If ADD is non-nil adds the new keys to `bibtex-reference-keys' instead of |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2157 simply resetting it. If VERBOSE is non-nil gives messages about |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2158 progress. If ABORTABLE is non-nil abort on user input. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2159 Return t if parsing was completed, nil if aborted." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2160 (let ((reference-keys (if add bibtex-reference-keys))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2161 (save-excursion |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2162 (save-match-data |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2163 (goto-char (point-min)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2164 (if verbose |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2165 (bibtex-progress-message |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2166 (concat (buffer-name) ": parsing reference keys"))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2167 (if (catch 'userkey |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2168 (while (bibtex-skip-to-valid-entry) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2169 (if (and abortable |
43418
b563c818c2b9
(bibtex-parse-keys): Put save-match-data around function body.
Eli Zaretskii <eliz@gnu.org>
parents:
43293
diff
changeset
|
2170 (input-pending-p)) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2171 (throw 'userkey t)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2172 (if verbose |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2173 (bibtex-progress-message)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2174 (let ((case-fold-search t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2175 key crossref-key bounds) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2176 (cond ((looking-at bibtex-entry-head) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2177 (setq key (bibtex-key-in-head)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2178 (let ((p (point)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2179 (m (bibtex-end-of-entry))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2180 (goto-char p) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2181 (if (setq bounds (bibtex-search-forward-field "crossref" m)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2182 (setq crossref-key (bibtex-text-in-field-bounds bounds t))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2183 ((setq bounds (bibtex-parse-string)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2184 (setq key (bibtex-reference-key-in-string bounds)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2185 (forward-char) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2186 (unless (assoc key reference-keys) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2187 (push (list key) reference-keys)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2188 (if (and crossref-key |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2189 (not (assoc crossref-key reference-keys))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2190 (push (list crossref-key) reference-keys))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2191 ;; user has aborted by typing a key --> return nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2192 nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2193 ;; successful operation --> return t |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2194 (setq bibtex-reference-keys reference-keys) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2195 (if verbose |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2196 (bibtex-progress-message 'done)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2197 t))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2198 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2199 (defun bibtex-parse-strings (&optional init abortable) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2200 "Set `bibtex-strings' to the string definitions in the whole buffer. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2201 The buffer might possibly be restricted. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2202 Optional arg INIT is used to initialize `bibtex-strings'. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2203 If ABORTABLE is non-nil abort on user input. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2204 Return t if parsing was completed, nil if aborted." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2205 (save-excursion |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2206 (save-match-data |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2207 (goto-char (point-min)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2208 (let ((strings init) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2209 bounds key) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2210 (if (catch 'userkey |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2211 (while (setq bounds (bibtex-search-forward-string)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2212 (if (and abortable |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2213 (input-pending-p)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2214 (throw 'userkey t)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2215 (setq key (bibtex-reference-key-in-string bounds)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2216 (if (not (assoc-ignore-case key strings)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2217 (push (cons key (bibtex-text-in-string bounds t)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2218 strings)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2219 (goto-char (bibtex-end-of-text-in-string bounds)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2220 ;; user has aborted by typing a key --> return nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2221 nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2222 ;; successful operation --> return t |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2223 (setq bibtex-strings strings) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2224 t))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2225 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2226 (defun bibtex-string-files-init () |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2227 "Return initialization for `bibtex-strings'. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2228 Use `bibtex-predefined-strings' and bib files `bibtex-string-files'." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2229 (save-match-data |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2230 ;; collect pathnames |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2231 (let ((dirlist (split-string (or bibtex-string-file-path ".") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2232 ":+")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2233 (case-fold-search) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2234 compl) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2235 (dolist (filename bibtex-string-files) |
51416
83476384bebd
(bibtex-member-of-regexp, bibtex-assoc-of-regexp, bibtex-format-entry)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51415
diff
changeset
|
2236 (unless (string-match "\\.bib\\'" filename) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2237 (setq filename (concat filename ".bib"))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2238 ;; test filenames |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2239 (let (fullfilename bounds found) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2240 (dolist (dir dirlist) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2241 (when (file-readable-p |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2242 (setq fullfilename (expand-file-name filename dir))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2243 ;; file was found |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2244 (with-temp-buffer |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2245 (insert-file-contents fullfilename) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2246 (goto-char (point-min)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2247 (while (setq bounds (bibtex-search-forward-string)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2248 (push (cons (bibtex-reference-key-in-string bounds) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2249 (bibtex-text-in-string bounds t)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2250 compl) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2251 (goto-char (bibtex-end-of-string bounds)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2252 (setq found t))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2253 (unless found |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2254 (error "File %s not in paths defined by bibtex-string-file-path variable" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2255 filename)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2256 (append bibtex-predefined-strings (nreverse compl))))) |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
2257 |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2258 (defun bibtex-parse-buffers-stealthily () |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2259 "Called by `bibtex-run-with-idle-timer'. Whenever emacs has been idle |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2260 for `bibtex-parse-keys-timeout' seconds, all BibTeX buffers (starting |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2261 with the current) are parsed." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2262 (save-excursion |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2263 (let ((buffers (buffer-list)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2264 (strings-init (bibtex-string-files-init))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2265 (while (and buffers (not (input-pending-p))) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2266 (set-buffer (car buffers)) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2267 (if (and (eq major-mode 'bibtex-mode) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2268 (not (eq (buffer-modified-tick) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2269 bibtex-buffer-last-parsed-tick))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2270 (save-restriction |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2271 (widen) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2272 ;; Output no progress messages in bibtex-parse-keys |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2273 ;; because when in y-or-n-p that can hide the question. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2274 (if (and (if bibtex-maintain-sorted-entries |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2275 (bibtex-parse-keys nil nil t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2276 t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2277 ;; update bibtex-strings |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2278 (bibtex-parse-strings strings-init t)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2279 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2280 ;; remember that parsing was successful |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2281 (setq bibtex-buffer-last-parsed-tick (buffer-modified-tick))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2282 (setq buffers (cdr buffers)))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2283 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2284 (defun bibtex-complete-internal (completions) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2285 "Complete word fragment before point to longest prefix of one |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2286 string defined in list COMPLETIONS. If point is not after the part |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2287 of a word, all strings are listed. Return completion." |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2288 (let* ((case-fold-search t) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2289 (beg (save-excursion |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2290 (re-search-backward "[ \t{\"]") |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2291 (forward-char) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2292 (point))) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2293 (end (point)) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2294 (part-of-word (buffer-substring-no-properties beg end)) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2295 (completion (try-completion part-of-word completions))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2296 (cond ((not completion) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2297 (error "Can't find completion for `%s'" part-of-word)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2298 ((eq completion t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2299 part-of-word) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2300 ((not (string= part-of-word completion)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2301 (delete-region beg end) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2302 (insert completion) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2303 completion) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2304 (t |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2305 (message "Making completion list...") |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2306 (with-output-to-temp-buffer "*Completions*" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2307 (display-completion-list (all-completions part-of-word |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2308 completions))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2309 (message "Making completion list...done") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2310 nil)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2311 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2312 (defun bibtex-complete-string-cleanup (str) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2313 "Remove enclosing field delimiters." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2314 (let ((pair (assoc str bibtex-strings))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2315 (when pair |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2316 (if (cdr pair) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2317 (message "Abbreviation for `%s'" (cdr pair))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2318 (save-excursion |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2319 (bibtex-inside-field) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2320 (let ((bounds (bibtex-enclosing-field))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2321 (goto-char (bibtex-start-of-text-in-field bounds)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2322 (let ((boundaries (bibtex-parse-field-string))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2323 (if (and boundaries |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2324 (equal (cdr boundaries) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2325 (bibtex-end-of-text-in-field bounds))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2326 (bibtex-remove-delimiters)))))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2327 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2328 (defun bibtex-choose-completion-string (choice buffer mini-p base-size) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2329 ;; Code borrowed from choose-completion-string: |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2330 ;; We must duplicate the code from choose-completion-string |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2331 ;; because it runs the hook choose-completion-string-functions |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2332 ;; before it inserts the completion. But we want to do something |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2333 ;; after the completion has been inserted. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2334 ;; |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2335 ;; Insert the completion into the buffer where it was requested. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2336 (set-buffer buffer) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2337 (if base-size |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2338 (delete-region (+ base-size (point-min)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2339 (point)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2340 ;; Delete the longest partial match for CHOICE |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2341 ;; that can be found before point. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2342 (choose-completion-delete-max-match choice)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2343 (insert choice) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2344 (remove-text-properties (- (point) (length choice)) (point) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2345 '(mouse-face nil)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2346 ;; Update point in the window that BUFFER is showing in. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2347 (let ((window (get-buffer-window buffer t))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2348 (set-window-point window (point)))) |
257 | 2349 |
14789
d68b71228abd
(bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents:
14410
diff
changeset
|
2350 (defun bibtex-pop (arg direction) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2351 "Generic function to be used by `bibtex-pop-previous' and `bibtex-pop-next'." |
14789
d68b71228abd
(bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents:
14410
diff
changeset
|
2352 (let (bibtex-help-message) |
d68b71228abd
(bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents:
14410
diff
changeset
|
2353 (bibtex-find-text nil)) |
257 | 2354 (save-excursion |
14789
d68b71228abd
(bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents:
14410
diff
changeset
|
2355 ;; parse current field |
d68b71228abd
(bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents:
14410
diff
changeset
|
2356 (bibtex-inside-field) |
27701
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
2357 (let* ((case-fold-search t) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2358 (bounds (bibtex-enclosing-field)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2359 (start-old-text (bibtex-start-of-text-in-field bounds)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2360 (stop-old-text (bibtex-end-of-text-in-field bounds)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2361 (start-name (bibtex-start-of-name-in-field bounds)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2362 (stop-name (bibtex-end-of-name-in-field bounds)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2363 ;; construct regexp for field with same name as this one, |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2364 ;; ignoring possible OPT's or ALT's |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2365 (field-name (progn |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2366 (goto-char start-name) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2367 (buffer-substring-no-properties |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2368 (if (looking-at "\\(OPT\\)\\|\\(ALT\\)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2369 (match-end 0) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2370 (point)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2371 stop-name)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2372 ;; if executed several times in a row, start each search where |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2373 ;; the last one was finished |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2374 (unless (eq last-command 'bibtex-pop) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2375 (bibtex-enclosing-entry-maybe-empty-head) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2376 (setq bibtex-pop-previous-search-point (match-beginning 0) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2377 bibtex-pop-next-search-point (point))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2378 (if (eq direction 'previous) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2379 (goto-char bibtex-pop-previous-search-point) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2380 (goto-char bibtex-pop-next-search-point)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2381 ;; Now search for arg'th previous/next similar field |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2382 (let (bounds failure new-text) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2383 (while (and (not failure) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2384 (> arg 0)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2385 (cond ((eq direction 'previous) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2386 (if (setq bounds (bibtex-search-backward-field field-name)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2387 (goto-char (bibtex-start-of-field bounds)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2388 (setq failure t))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2389 ((eq direction 'next) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2390 (if (setq bounds (bibtex-search-forward-field field-name)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2391 (goto-char (bibtex-end-of-field bounds)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2392 (setq failure t)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2393 (setq arg (- arg 1))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2394 (if failure |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2395 (error "No %s matching BibTeX field" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2396 (if (eq direction 'previous) "previous" "next")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2397 ;; Found a matching field. Remember boundaries. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2398 (setq bibtex-pop-previous-search-point (bibtex-start-of-field bounds) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2399 bibtex-pop-next-search-point (bibtex-end-of-field bounds) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2400 new-text (bibtex-text-in-field-bounds bounds)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2401 (bibtex-flash-head) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2402 ;; Go back to where we started, delete old text, and pop new. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2403 (goto-char stop-old-text) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2404 (delete-region start-old-text stop-old-text) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2405 (insert new-text))))) |
14789
d68b71228abd
(bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents:
14410
diff
changeset
|
2406 (let (bibtex-help-message) |
d68b71228abd
(bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents:
14410
diff
changeset
|
2407 (bibtex-find-text nil)) |
d68b71228abd
(bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents:
14410
diff
changeset
|
2408 (setq this-command 'bibtex-pop)) |
d68b71228abd
(bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents:
14410
diff
changeset
|
2409 |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2410 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2411 ;; Interactive Functions: |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2412 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2413 ;;;###autoload |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2414 (defun bibtex-mode () |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2415 "Major mode for editing BibTeX files. |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2416 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2417 General information on working with BibTeX mode: |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2418 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2419 You should use commands as \\[bibtex-Book] to get a template for a |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2420 specific entry. You should then fill in all desired fields using |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2421 \\[bibtex-next-field] to jump from field to field. After having filled |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2422 in all desired fields in the entry, you should clean the new entry |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2423 with command \\[bibtex-clean-entry]. |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2424 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2425 Some features of BibTeX mode are available only by setting variable |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2426 `bibtex-maintain-sorted-entries' to t. However, then BibTeX mode will |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2427 work with buffer containing only valid (syntactical correct) entries |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2428 and with entries being sorted. This is usually the case, if you have |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2429 created a buffer completely with BibTeX mode and finished every new |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2430 entry with \\[bibtex-clean-entry]. |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2431 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2432 For third party BibTeX buffers, please call the function |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2433 `bibtex-convert-alien' to fully take advantage of all features of |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2434 BibTeX mode. |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2435 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2436 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2437 Special information: |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2438 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2439 A command such as \\[bibtex-Book] will outline the fields for a BibTeX book entry. |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2440 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2441 The optional fields start with the string OPT, and are thus ignored by BibTeX. |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2442 Alternatives from which only one is required start with the string ALT. |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2443 The OPT or ALT string may be removed from a field with \\[bibtex-remove-OPT-or-ALT]. |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2444 \\[bibtex-make-field] inserts a new field after the current one. |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2445 \\[bibtex-kill-field] kills the current field entirely. |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2446 \\[bibtex-yank] will yank the last recently killed field after the |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2447 current field. |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2448 \\[bibtex-remove-delimiters] removes the double-quotes or braces around the text of the current field. |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2449 \\[bibtex-empty-field] replaces the text of the current field with the default \"\" or {}. |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2450 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2451 The command \\[bibtex-clean-entry] cleans the current entry, i.e. it removes OPT/ALT |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2452 from all non-empty optional or alternative fields, checks that no required |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2453 fields are empty, and does some formatting dependent on the value of |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2454 `bibtex-entry-format'. |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
2455 Note: some functions in BibTeX mode depend on entries being in a special |
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
2456 format (all fields beginning on separate lines), so it is usually a bad |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2457 idea to remove `realign' from `bibtex-entry-format'. |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2458 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2459 Use \\[bibtex-find-text] to position the cursor at the end of the current field. |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2460 Use \\[bibtex-next-field] to move to end of the next field. |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2461 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2462 The following may be of interest as well: |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2463 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2464 Functions: |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2465 `bibtex-entry' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2466 `bibtex-kill-entry' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2467 `bibtex-yank-pop' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2468 `bibtex-pop-previous' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2469 `bibtex-pop-next' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2470 `bibtex-complete' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2471 `bibtex-print-help-message' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2472 `bibtex-generate-autokey' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2473 `bibtex-beginning-of-entry' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2474 `bibtex-end-of-entry' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2475 `bibtex-reposition-window' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2476 `bibtex-mark-entry' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2477 `bibtex-ispell-abstract' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2478 `bibtex-ispell-entry' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2479 `bibtex-narrow-to-entry' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2480 `bibtex-sort-buffer' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2481 `bibtex-validate' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2482 `bibtex-count' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2483 `bibtex-fill-entry' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2484 `bibtex-reformat' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2485 `bibtex-convert-alien' |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2486 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2487 Variables: |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2488 `bibtex-field-delimiters' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2489 `bibtex-include-OPTcrossref' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2490 `bibtex-include-OPTkey' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2491 `bibtex-user-optional-fields' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2492 `bibtex-entry-format' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2493 `bibtex-sort-ignore-string-entries' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2494 `bibtex-maintain-sorted-entries' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2495 `bibtex-entry-field-alist' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2496 `bibtex-predefined-strings' |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2497 `bibtex-string-files' |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2498 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2499 --------------------------------------------------------- |
19461 | 2500 Entry to BibTeX mode calls the value of `bibtex-mode-hook' if that value is |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2501 non-nil. |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2502 |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
2503 \\{bibtex-mode-map}" |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2504 (interactive) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2505 (kill-all-local-variables) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2506 (use-local-map bibtex-mode-map) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2507 (setq major-mode 'bibtex-mode) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2508 (setq mode-name "BibTeX") |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2509 (set-syntax-table bibtex-mode-syntax-table) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2510 (make-local-variable 'bibtex-strings) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2511 (make-local-variable 'bibtex-reference-keys) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2512 (make-local-variable 'bibtex-buffer-last-parsed-tick) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2513 (bibtex-parse-strings (bibtex-string-files-init)) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2514 (if bibtex-maintain-sorted-entries |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2515 (bibtex-parse-keys nil nil t)) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2516 ;; Install stealthy parse function if not already installed |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2517 (unless bibtex-parse-idle-timer |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2518 (setq bibtex-parse-idle-timer (bibtex-run-with-idle-timer |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2519 bibtex-parse-keys-timeout t |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2520 'bibtex-parse-buffers-stealthily))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2521 (set (make-local-variable 'paragraph-start) "[ \f\n\t]*$") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2522 (set (make-local-variable 'comment-start) bibtex-comment-start) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2523 (set (make-local-variable 'comment-start-skip) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2524 (concat (regexp-quote bibtex-comment-start) "\\>[ \t]*")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2525 (set (make-local-variable 'comment-column) 0) |
51416
83476384bebd
(bibtex-member-of-regexp, bibtex-assoc-of-regexp, bibtex-format-entry)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51415
diff
changeset
|
2526 (set (make-local-variable 'defun-prompt-regexp) "^[ \t]*@[a-zA-Z0-9]+[ \t]*") |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2527 (set (make-local-variable 'outline-regexp) "[ \t]*@") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2528 (set (make-local-variable 'fill-prefix) (make-string (+ bibtex-entry-offset |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2529 bibtex-contline-indentation) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2530 ? )) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2531 (set (make-local-variable 'font-lock-defaults) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2532 '(bibtex-font-lock-keywords |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2533 nil t ((?$ . "\"") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2534 ;; Mathematical expressions should be fontified as strings |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2535 (?\" . ".") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2536 ;; Quotes are field delimiters and quote-delimited |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2537 ;; entries should be fontified in the same way as |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2538 ;; brace-delimited ones |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2539 ) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2540 nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2541 (font-lock-syntactic-keywords . bibtex-font-lock-syntactic-keywords))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2542 (set (make-local-variable 'font-lock-mark-block-function) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2543 (lambda () |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2544 (set-mark (bibtex-end-of-entry)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2545 (bibtex-beginning-of-entry))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2546 (setq imenu-generic-expression |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2547 (list (list nil bibtex-entry-head bibtex-key-in-head))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2548 (make-local-variable 'choose-completion-string-functions) |
20459 | 2549 (setq imenu-case-fold-search t) |
20907
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2550 ;; XEmacs needs easy-menu-add, Emacs does not care |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2551 (easy-menu-add bibtex-edit-menu) |
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
2552 (easy-menu-add bibtex-entry-menu) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2553 (run-hooks 'bibtex-mode-hook)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2554 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2555 (defun bibtex-entry (entry-type) |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
2556 "Insert a new BibTeX entry. |
19461 | 2557 After insertion it calls the functions in `bibtex-add-entry-hook'." |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2558 (interactive (let* ((completion-ignore-case t) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2559 (e-t (completing-read |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2560 "Entry Type: " |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2561 bibtex-entry-field-alist |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2562 nil t nil 'bibtex-entry-type-history))) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2563 (list e-t))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2564 (unless (consp bibtex-reference-keys) (bibtex-parse-keys nil t)) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2565 (let* (required |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2566 optional |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2567 (key (if bibtex-maintain-sorted-entries |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2568 (completing-read (format "%s key: " entry-type) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2569 bibtex-reference-keys |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2570 nil nil nil 'bibtex-key-history))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2571 (e (assoc-ignore-case entry-type bibtex-entry-field-alist)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2572 (r-n-o (elt e 1)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2573 (c-ref (elt e 2))) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2574 (if (not e) |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
2575 (error "Bibtex entry type %s not defined" entry-type)) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2576 (if (and (member entry-type bibtex-include-OPTcrossref) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2577 c-ref) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2578 (setq required (elt c-ref 0) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2579 optional (elt c-ref 1)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2580 (setq required (elt r-n-o 0) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2581 optional (elt r-n-o 1))) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2582 (unless (bibtex-prepare-new-entry (list key nil entry-type)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2583 (error "Entry with key `%s' already exists" key)) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2584 (indent-to-column bibtex-entry-offset) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2585 (insert "@" entry-type (bibtex-entry-left-delimiter)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2586 (if key |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2587 (insert key)) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2588 (save-excursion |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2589 (mapcar 'bibtex-make-field required) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2590 (if (member entry-type bibtex-include-OPTcrossref) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2591 (bibtex-make-optional-field '("crossref"))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2592 (if bibtex-include-OPTkey |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2593 (if (or (stringp bibtex-include-OPTkey) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2594 (fboundp bibtex-include-OPTkey)) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2595 (bibtex-make-optional-field |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2596 (list "key" nil bibtex-include-OPTkey)) |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
2597 (bibtex-make-optional-field '("key")))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2598 (mapcar 'bibtex-make-optional-field optional) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2599 (mapcar 'bibtex-make-optional-field bibtex-user-optional-fields) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2600 (if bibtex-comma-after-last-field |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2601 (insert ",")) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2602 (insert "\n") |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2603 (indent-to-column bibtex-entry-offset) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2604 (insert (bibtex-entry-right-delimiter) "\n\n")) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2605 (bibtex-next-field t) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2606 (run-hooks 'bibtex-add-entry-hook))) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2607 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2608 (defun bibtex-print-help-message () |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2609 "Print helpful information about current field in current BibTeX entry." |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2610 (interactive) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2611 (save-excursion |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2612 (let* ((case-fold-search t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2613 (bounds (bibtex-enclosing-field)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2614 (mb (bibtex-start-of-name-in-field bounds)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2615 (field-name (buffer-substring-no-properties |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2616 (if (progn (goto-char mb) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2617 (looking-at "OPT\\|ALT")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2618 (+ 3 mb) mb) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2619 (bibtex-end-of-name-in-field bounds))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2620 (entry-type (progn (re-search-backward |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2621 bibtex-entry-maybe-empty-head nil t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2622 (bibtex-type-in-head))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2623 (entry-list (assoc-ignore-case entry-type |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2624 bibtex-entry-field-alist)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2625 (c-r-list (elt entry-list 2)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2626 (req-opt-list (if (and (member entry-type |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2627 bibtex-include-OPTcrossref) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2628 c-r-list) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2629 c-r-list |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2630 (elt entry-list 1))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2631 (list-of-entries (append (elt req-opt-list 0) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2632 (elt req-opt-list 1) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2633 bibtex-user-optional-fields |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2634 (if (member entry-type |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2635 bibtex-include-OPTcrossref) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2636 '(("crossref" "Reference key of the cross-referenced entry"))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2637 (if bibtex-include-OPTkey |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2638 '(("key" "Used for reference key creation if author and editor fields are missing"))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2639 (comment (assoc-ignore-case field-name list-of-entries))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2640 (if comment |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2641 (message (elt comment 1)) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2642 (message "No comment available"))))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2643 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2644 (defun bibtex-make-field (e-t &optional called-by-yank) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2645 "Make a field named E-T in current BibTeX entry." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2646 (interactive |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2647 (list (let* ((entry-type |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2648 (save-excursion |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2649 (bibtex-enclosing-entry-maybe-empty-head) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2650 (bibtex-type-in-head))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2651 (fl (cadr (assoc-ignore-case |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2652 entry-type bibtex-entry-field-alist))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2653 (field-list (append (elt fl 0) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2654 (elt fl 1) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2655 bibtex-user-optional-fields |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2656 (if bibtex-include-OPTcrossref |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2657 '(("crossref" nil))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2658 (if bibtex-include-OPTkey |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2659 '(("key" nil))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2660 (completion-ignore-case t)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2661 (completing-read "BibTeX field name: " field-list |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2662 nil nil nil bibtex-field-history)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2663 (unless (consp e-t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2664 (setq e-t (list e-t))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2665 (let ((name (if (elt e-t 3) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2666 (concat "ALT" (car e-t)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2667 (car e-t)))) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2668 (if (or (interactive-p) called-by-yank) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2669 (let (bibtex-help-message) |
43758
300d944f45f6
* textmodes/bibtex.el (bibtex-make-field): Call bibtex-find-text
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
43418
diff
changeset
|
2670 (bibtex-find-text nil t t) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2671 (if (looking-at "[}\"]") |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2672 (forward-char)))) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2673 (insert ",\n") |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2674 (indent-to-column (+ bibtex-entry-offset bibtex-field-indentation)) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2675 (insert name " ") |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2676 (if bibtex-align-at-equal-sign |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2677 (indent-to-column (+ bibtex-entry-offset |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2678 (- bibtex-text-indentation 2)))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2679 (insert "= ") |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2680 (if (not bibtex-align-at-equal-sign) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2681 (indent-to-column (+ bibtex-entry-offset |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2682 bibtex-text-indentation))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2683 (insert (if called-by-yank |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2684 "" |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2685 (bibtex-field-left-delimiter)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2686 (let ((init (elt e-t 2))) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2687 (cond ((stringp init) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2688 init) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2689 ((fboundp init) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2690 (funcall init)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2691 (t ""))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2692 (if called-by-yank |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2693 "" |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2694 (bibtex-field-right-delimiter))) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2695 (if (interactive-p) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2696 (forward-char -1)))) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2697 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2698 (defun bibtex-beginning-of-entry () |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2699 "Move to beginning of BibTeX entry (beginning of line). |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2700 If inside an entry, move to the beginning of it, otherwise move to the |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2701 beginning of the previous entry. |
19461 | 2702 If called from a program, this function returns the new location of point." |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2703 (interactive) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2704 (skip-chars-forward " \t") |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2705 (if (looking-at "@") |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2706 (forward-char)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2707 (re-search-backward "^[ \t]*@" nil 'move)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2708 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2709 (defun bibtex-end-of-entry () |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2710 "Move to end of BibTeX entry (past the closing brace). |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2711 If inside an entry, move to the end of it, otherwise move to the end |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2712 of the previous entry. Do not move if ahead of first entry. |
19461 | 2713 If called from a program, this function returns the new location of point." |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2714 (interactive) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2715 (let ((case-fold-search t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2716 (org (point)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2717 (pnt (bibtex-beginning-of-entry)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2718 err bounds) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2719 (cond ((setq bounds (bibtex-parse-string)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2720 (goto-char (bibtex-end-of-string bounds))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2721 ((looking-at "[ \t]*@[ \t]*preamble[ \t\n]*") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2722 (goto-char (match-end 0)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2723 (cond ((looking-at "(") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2724 (unless (re-search-forward ")[ \t]*\n\n" nil 'move) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2725 (setq err t))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2726 ((looking-at "{") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2727 (unless (re-search-forward "}[ \t]*\n\n" nil 'move) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2728 (setq err t))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2729 (t |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2730 (setq err t))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2731 (unless err |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2732 (goto-char (match-beginning 0)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2733 (forward-char))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2734 ((looking-at bibtex-valid-entry-whitespace-re) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2735 (bibtex-search-entry t nil t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2736 (unless (equal (match-beginning 0) pnt) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2737 (setq err t))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2738 (t |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2739 (if (interactive-p) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2740 (message "Not on a known BibTeX entry.")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2741 (goto-char org))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2742 (when err |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2743 (goto-char pnt) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2744 (error "Syntactically incorrect BibTeX entry starts here"))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2745 (point)) |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
2746 |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2747 (defun bibtex-reposition-window (&optional arg) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2748 "Make the current BibTeX entry visible. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2749 Optional argument ARG is exactly as in `recenter'." |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2750 (interactive "P") |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2751 (save-excursion |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2752 (goto-char |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2753 (/ (+ (bibtex-beginning-of-entry) (bibtex-end-of-entry)) 2)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2754 (recenter arg))) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2755 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2756 (defun bibtex-mark-entry () |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2757 "Put mark at beginning, point at end of current BibTeX entry." |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2758 (interactive) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2759 (set-mark (bibtex-beginning-of-entry)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2760 (bibtex-end-of-entry)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2761 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2762 (defun bibtex-count-entries (&optional count-string-entries) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2763 "Count number of entries in current buffer or region. |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
2764 With prefix argument COUNT-STRING-ENTRIES it counts all entries, |
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
2765 otherwise it counts all except Strings. |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2766 If mark is active it counts entries in region, if not in whole buffer." |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2767 (interactive "P") |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2768 (let ((number 0) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2769 (bibtex-sort-ignore-string-entries |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2770 (not count-string-entries))) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2771 (save-excursion |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2772 (save-restriction |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2773 (narrow-to-region (if (bibtex-mark-active) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2774 (region-beginning) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2775 (bibtex-beginning-of-first-entry)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2776 (if (bibtex-mark-active) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2777 (region-end) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2778 (point-max))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2779 (goto-char (point-min)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2780 (bibtex-map-entries (lambda (current) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2781 (setq number (1+ number)))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2782 (message "%s contains %d entries." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2783 (if (bibtex-mark-active) "Region" "Buffer") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2784 number))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2785 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2786 (defun bibtex-ispell-entry () |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2787 "Spell whole BibTeX entry." |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2788 (interactive) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2789 (ispell-region (bibtex-beginning-of-entry) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2790 (bibtex-end-of-entry))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2791 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2792 (defun bibtex-ispell-abstract () |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2793 "Spell abstract of BibTeX entry." |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2794 (interactive) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2795 (bibtex-beginning-of-entry) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2796 (let ((bounds (bibtex-search-forward-field "abstract" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2797 (bibtex-end-of-entry)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2798 (if bounds |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2799 (ispell-region (bibtex-start-of-text-in-field bounds) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2800 (bibtex-end-of-text-in-field bounds)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2801 (error "No abstract in entry")))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2802 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2803 (defun bibtex-narrow-to-entry () |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2804 "Narrow buffer to current BibTeX entry." |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2805 (interactive) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2806 (save-excursion |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2807 (widen) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2808 (narrow-to-region (bibtex-beginning-of-entry) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2809 (bibtex-end-of-entry)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2810 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2811 (defun bibtex-entry-index () |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2812 "Return the index of the BibTeX entry at point. Move point. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2813 The index is a list (KEY CROSSREF-KEY ENTRY-NAME) that is used for sorting |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2814 the entries of the BibTeX buffer. Return nil if no entry found." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2815 (let ((case-fold-search t)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2816 (if (re-search-forward bibtex-entry-maybe-empty-head nil t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2817 (let ((key (bibtex-key-in-head)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2818 (entry-name (bibtex-type-in-head))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2819 ;; Don't search CROSSREF-KEY if we don't need it. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2820 (if (equal bibtex-maintain-sorted-entries 'crossref) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2821 (save-excursion |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2822 (save-restriction |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2823 (bibtex-narrow-to-entry) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2824 (goto-char (point-min)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2825 (let ((bounds (bibtex-search-forward-field |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2826 "\\(OPT\\)?crossref"))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2827 (list key |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2828 (if bounds (bibtex-text-in-field-bounds bounds t)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2829 entry-name)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2830 (list key nil entry-name)))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2831 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2832 (defun bibtex-lessp (index1 index2) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2833 "Predicate for sorting BibTeX entries with indices INDEX1 and INDEX2. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2834 Each index is a list (KEY CROSSREF-KEY ENTRY-NAME). |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2835 The predicate depends on the variable `bibtex-maintain-sorted-entries'." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2836 (cond ((not index1) (not index2)) ; indices can be nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2837 ((not index2) nil) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2838 ((equal bibtex-maintain-sorted-entries 'crossref) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2839 (if (nth 1 index1) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2840 (if (nth 1 index2) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2841 (or (string-lessp (nth 1 index1) (nth 1 index2)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2842 (and (string-equal (nth 1 index1) (nth 1 index2)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2843 (string-lessp (nth 0 index1) (nth 0 index2)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2844 (not (string-lessp (nth 0 index2) (nth 1 index1)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2845 (if (nth 1 index2) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2846 (string-lessp (nth 0 index1) (nth 1 index2)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2847 (string-lessp (nth 0 index1) (nth 0 index2))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2848 ((equal bibtex-maintain-sorted-entries 'entry-class) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2849 (let ((n1 (cdr (assoc-ignore-case (nth 2 index1) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2850 bibtex-sort-entry-class-alist))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2851 (n2 (cdr (assoc-ignore-case (nth 2 index2) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2852 bibtex-sort-entry-class-alist)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2853 (or (< n1 n2) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2854 (and (= n1 n2) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2855 (string-lessp (car index1) (car index2)))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2856 (t ; (equal bibtex-maintain-sorted-entries 'plain) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2857 (string-lessp (car index1) (car index2))))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2858 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2859 (defun bibtex-sort-buffer () |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2860 "Sort BibTeX buffer alphabetically by key. |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2861 The predicate for sorting is defined via `bibtex-maintain-sorted-entries'. |
19461 | 2862 Text outside of BibTeX entries is not affected. If |
2863 `bibtex-sort-ignore-string-entries' is non-nil, @String entries will be | |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2864 ignored." |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2865 (interactive) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2866 (unless bibtex-maintain-sorted-entries |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2867 (error "You must choose a sorting scheme")) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2868 (save-restriction |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2869 (narrow-to-region (bibtex-beginning-of-first-entry) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2870 (save-excursion (goto-char (point-max)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2871 (bibtex-end-of-entry))) |
18247
ae094c1a4334
(bibtex-delete-whitespace, bibtex-current-line)
Richard M. Stallman <rms@gnu.org>
parents:
18212
diff
changeset
|
2872 (bibtex-skip-to-valid-entry) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2873 (sort-subr nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2874 'bibtex-skip-to-valid-entry ; NEXTREC function |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2875 'bibtex-end-of-entry ; ENDREC function |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2876 'bibtex-entry-index ; STARTKEY function |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2877 nil ; ENDKEY function |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2878 'bibtex-lessp))) ; PREDICATE |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2879 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2880 (defun bibtex-find-crossref (crossref-key) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2881 "Move point to the beginning of BibTeX entry CROSSREF-KEY. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2882 Return position of entry if CROSSREF-KEY is found and nil otherwise. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2883 If position of current entry is after CROSSREF-KEY an error is signaled." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2884 (let ((pos (save-excursion (bibtex-find-entry crossref-key)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2885 (if (and pos (> (point) pos)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2886 (error "This entry must not follow the crossrefed entry!")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2887 (goto-char pos))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2888 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2889 (defun bibtex-find-entry (key) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2890 "Move point to the beginning of BibTeX entry named KEY. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2891 Return position of entry if KEY is found or nil if not found." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2892 (interactive |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2893 (list (if bibtex-maintain-sorted-entries |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2894 (completing-read "Find key: " |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2895 bibtex-reference-keys |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2896 nil nil nil 'bibtex-key-history) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2897 (read-from-minibuffer "Find key: " nil nil nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2898 'bibtex-key-history)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2899 (let* (case-fold-search |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2900 (pnt (save-excursion |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2901 (goto-char (point-min)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2902 (when (re-search-forward (concat "^[ \t]*\\(" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2903 bibtex-entry-type |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2904 "\\)[ \t]*[({][ \t\n]*\\(" |
51416
83476384bebd
(bibtex-member-of-regexp, bibtex-assoc-of-regexp, bibtex-format-entry)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51415
diff
changeset
|
2905 (regexp-quote key) "\\)") |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2906 nil t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2907 (match-beginning 2))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2908 (cond (pnt |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2909 (goto-char pnt) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2910 (bibtex-beginning-of-entry)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2911 ((interactive-p) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2912 (message "Key `%s' not found" key))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2913 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2914 (defun bibtex-prepare-new-entry (index) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2915 "Prepare a new BibTeX entry with index INDEX. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2916 INDEX is a list (KEY CROSSREF-KEY ENTRY-NAME). |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2917 Move point where the entry KEY should be placed. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2918 If `bibtex-maintain-sorted-entries' is non-nil, perform a binary |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2919 search to look for place for KEY. This will fail if buffer is not in |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2920 sorted order, see \\[bibtex-validate].) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2921 Return t if preparation was successful or nil if entry KEY already exists." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2922 (let ((key (nth 0 index)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2923 key-exist) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2924 (cond ((or (null key) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2925 (and (stringp key) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2926 (string-equal key "")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2927 (and (not (setq key-exist (bibtex-find-entry key))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2928 (not bibtex-maintain-sorted-entries))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2929 (bibtex-move-outside-of-entry)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2930 ;; if key-exist is non-nil due to the previous cond clause |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2931 ;; then point will be at beginning of entry named key. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2932 (key-exist) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2933 (t ; bibtex-maintain-sorted-entries is non-nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2934 (let* ((case-fold-search t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2935 (left (save-excursion (bibtex-beginning-of-first-entry) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2936 (bibtex-skip-to-valid-entry) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2937 (point))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2938 (right (save-excursion (bibtex-beginning-of-last-entry) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2939 (bibtex-end-of-entry))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2940 (found (if (>= left right) left)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2941 actual-index new) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2942 (save-excursion |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2943 ;; Binary search |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2944 (while (not found) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2945 (goto-char (/ (+ left right) 2)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2946 (bibtex-skip-to-valid-entry t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2947 (setq actual-index (bibtex-entry-index)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2948 (cond ((bibtex-lessp index actual-index) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2949 (setq new (bibtex-beginning-of-entry)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2950 (if (equal right new) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2951 (setq found right) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2952 (setq right new))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2953 (t |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2954 (bibtex-end-of-entry) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2955 (bibtex-skip-to-valid-entry) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2956 (setq new (point)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2957 (if (equal left new) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2958 (setq found right) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2959 (setq left new)))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2960 (goto-char found) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2961 (bibtex-beginning-of-entry) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2962 (setq actual-index (save-excursion (bibtex-entry-index))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2963 (when (or (not actual-index) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2964 (bibtex-lessp actual-index index)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2965 ;; buffer contains no valid entries or |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2966 ;; greater than last entry --> append |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2967 (bibtex-end-of-entry) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2968 (if (not (bobp)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2969 (newline (forward-line 2))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2970 (beginning-of-line))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2971 (unless key-exist t))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2972 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2973 (defun bibtex-validate (&optional test-thoroughly) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2974 "Validate if buffer or region is syntactically correct. |
27701
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
2975 Only known entry types are checked, so you can put comments |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2976 outside of entries. |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2977 With optional argument TEST-THOROUGHLY non-nil it checks for absence of |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2978 required fields and questionable month fields as well. |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2979 If mark is active, validate current region, if not the whole buffer. |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2980 Returns t if test was successful, nil otherwise." |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
2981 (interactive "P") |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2982 (let* ((case-fold-search t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2983 error-list syntax-error) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2984 (save-excursion |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2985 (save-restriction |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2986 (narrow-to-region (if (bibtex-mark-active) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2987 (region-beginning) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2988 (bibtex-beginning-of-first-entry)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2989 (if (bibtex-mark-active) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2990 (region-end) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2991 (point-max))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2992 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2993 ;; looking if entries fit syntactical structure |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2994 (goto-char (point-min)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2995 (bibtex-progress-message "Checking syntactical structure") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2996 (let (bibtex-sort-ignore-string-entries) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2997 (while (re-search-forward "^[ \t]*@" nil t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2998 (bibtex-progress-message) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
2999 (forward-char -1) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3000 (let ((pnt (point))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3001 (if (not (looking-at bibtex-any-valid-entry-re)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3002 (forward-char) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3003 (bibtex-skip-to-valid-entry) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3004 (if (equal (point) pnt) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3005 (forward-char) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3006 (goto-char pnt) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3007 (push (list (bibtex-current-line) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3008 "Syntax error (check esp. commas, braces, and quotes)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3009 error-list) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3010 (forward-char)))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3011 (bibtex-progress-message 'done) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3012 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3013 (if error-list |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3014 (setq syntax-error t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3015 ;; looking for correct sort order and duplicates (only if |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3016 ;; there were no syntax errors) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3017 (if bibtex-maintain-sorted-entries |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3018 (let (previous current) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3019 (goto-char (point-min)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3020 (bibtex-progress-message "Checking correct sort order") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3021 (bibtex-map-entries |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3022 (lambda (dummy) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3023 (bibtex-progress-message) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3024 (bibtex-beginning-of-entry) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3025 (setq current (bibtex-entry-index)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3026 (cond ((or (not previous) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3027 (bibtex-lessp previous current)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3028 (setq previous current)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3029 ((string-equal (car previous) (car current)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3030 (push (list (bibtex-current-line) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3031 "Duplicate key with previous") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3032 error-list)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3033 (t |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3034 (setq previous current) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3035 (push (list (bibtex-current-line) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3036 "Entries out of order") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3037 error-list))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3038 (bibtex-progress-message 'done))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3039 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3040 (when test-thoroughly |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3041 (goto-char (point-min)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3042 (bibtex-progress-message |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3043 "Checking required fields and month fields") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3044 (let ((bibtex-sort-ignore-string-entries t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3045 (questionable-month |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3046 (regexp-opt (mapcar 'car bibtex-predefined-month-strings)))) |
18247
ae094c1a4334
(bibtex-delete-whitespace, bibtex-current-line)
Richard M. Stallman <rms@gnu.org>
parents:
18212
diff
changeset
|
3047 (bibtex-map-entries |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3048 (lambda (current) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3049 (bibtex-progress-message) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3050 (let* ((beg (bibtex-beginning-of-entry)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3051 (end (bibtex-end-of-entry)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3052 (entry-list (progn |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3053 (goto-char beg) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3054 (bibtex-search-entry nil end) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3055 (assoc-ignore-case (bibtex-type-in-head) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3056 bibtex-entry-field-alist))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3057 (req (copy-sequence (elt (elt entry-list 1) 0))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3058 (creq (copy-sequence (elt (elt entry-list 2) 0))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3059 crossref-there bounds) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3060 (goto-char beg) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3061 (while (setq bounds (bibtex-search-forward-field |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3062 bibtex-field-name end)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3063 (goto-char (bibtex-start-of-text-in-field bounds)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3064 (let ((field-name (downcase (bibtex-name-in-field bounds))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3065 case-fold-search) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3066 (if (and (equal field-name "month") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3067 (not (string-match questionable-month |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3068 (bibtex-text-in-field-bounds bounds)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3069 (push (list (bibtex-current-line) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3070 "Questionable month field") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3071 error-list)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3072 (setq req (delete (assoc-ignore-case field-name req) req) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3073 creq (delete (assoc-ignore-case field-name creq) creq)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3074 (if (equal field-name "crossref") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3075 (setq crossref-there t)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3076 (if crossref-there |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3077 (setq req creq)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3078 (if (or (> (length req) 1) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3079 (and (= (length req) 1) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3080 (not (elt (car req) 3)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3081 ;; two (or more) fields missed or one field |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3082 ;; missed and this isn't flagged alternative |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3083 ;; (notice that this fails if there are more |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3084 ;; than two alternatives in a BibTeX entry, |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3085 ;; which isn't the case momentarily) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3086 (push (list (save-excursion |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3087 (bibtex-beginning-of-entry) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3088 (bibtex-current-line)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3089 (concat "Required field `" (caar req) "' missing")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3090 error-list)))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3091 (bibtex-progress-message 'done))))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3092 (if error-list |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3093 (let ((bufnam (buffer-name)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3094 (dir default-directory)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3095 (setq error-list |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3096 (sort error-list |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3097 (lambda (a b) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3098 (< (car a) (car b))))) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3099 (let ((pop-up-windows t)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3100 (pop-to-buffer nil t)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3101 (switch-to-buffer |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3102 (get-buffer-create "*BibTeX validation errors*") t) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3103 ;; don't use switch-to-buffer-other-window, since this |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3104 ;; doesn't allow the second parameter NORECORD |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3105 (setq default-directory dir) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3106 (toggle-read-only -1) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3107 (compilation-mode) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3108 (delete-region (point-min) (point-max)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3109 (goto-char (point-min)) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3110 (insert "BibTeX mode command `bibtex-validate'\n" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3111 (if syntax-error |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3112 "Maybe undetected errors due to syntax errors. Correct and validate again." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3113 "") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3114 "\n") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3115 (dolist (err error-list) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3116 (insert bufnam ":" (number-to-string (elt err 0)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3117 ": " (elt err 1) "\n")) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3118 (compilation-parse-errors nil nil) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3119 (setq compilation-old-error-list compilation-error-list) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3120 ;; this is necessary to avoid reparsing of buffer if you |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3121 ;; switch to compilation buffer and enter `compile-goto-error' |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3122 (set-buffer-modified-p nil) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3123 (toggle-read-only 1) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3124 (goto-char (point-min)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3125 (other-window -1) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3126 ;; return nil |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3127 nil) |
20907
9a55a557cb5a
(bibtex-autokey-names): Change number tag to integer.
Richard M. Stallman <rms@gnu.org>
parents:
20866
diff
changeset
|
3128 (if (bibtex-mark-active) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3129 (message "Region is syntactically correct") |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3130 (message "Buffer is syntactically correct")) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3131 t))) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3132 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3133 (defun bibtex-next-field (arg) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3134 "Find end of text of next BibTeX field; with ARG, to its beginning." |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3135 (interactive "P") |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3136 (bibtex-inside-field) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3137 (let ((start (point))) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3138 (condition-case () |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3139 (let ((bounds (bibtex-enclosing-field))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3140 (goto-char (bibtex-end-of-field bounds)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3141 (forward-char 2)) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3142 (error |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3143 (goto-char start) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3144 (end-of-line) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3145 (forward-char)))) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3146 (bibtex-find-text arg t)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3147 |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3148 (defun bibtex-find-text (arg &optional as-if-interactive no-error) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3149 "Go to end of text of current field; with ARG, go to beginning." |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3150 (interactive "P") |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3151 (bibtex-inside-field) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3152 (let ((bounds (bibtex-enclosing-field (or (interactive-p) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3153 as-if-interactive)))) |
27701
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
3154 (if bounds |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3155 (progn (if arg |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3156 (progn (goto-char (bibtex-start-of-text-in-field bounds)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3157 (if (looking-at "[{\"]") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3158 (forward-char))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3159 (goto-char (bibtex-end-of-text-in-field bounds)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3160 (if (or (= (preceding-char) ?}) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3161 (= (preceding-char) ?\")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3162 (forward-char -1))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3163 (if bibtex-help-message |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3164 (bibtex-print-help-message))) |
27701
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
3165 (beginning-of-line) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3166 (cond ((setq bounds (bibtex-parse-string)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3167 (goto-char (if arg |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3168 (bibtex-start-of-text-in-string bounds) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3169 (bibtex-end-of-text-in-string bounds)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3170 ((looking-at bibtex-entry-maybe-empty-head) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3171 (goto-char (if arg |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3172 (match-beginning bibtex-key-in-head) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3173 (match-end 0)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3174 (t |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3175 (unless no-error |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3176 (error "Not on BibTeX field"))))))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3177 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3178 (defun bibtex-remove-OPT-or-ALT () |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3179 "Remove the string starting optional/alternative fields. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3180 Align text and go thereafter to end of text." |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3181 (interactive) |
27701
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
3182 (bibtex-inside-field) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3183 (let ((case-fold-search t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3184 (bounds (bibtex-enclosing-field))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3185 (save-excursion |
27701
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
3186 (goto-char (bibtex-start-of-name-in-field bounds)) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3187 (when (looking-at "OPT\\|ALT") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3188 (delete-char (length "OPT")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3189 ;; make field non-OPT |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3190 (search-forward "=") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3191 (forward-char -1) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3192 (delete-horizontal-space) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3193 (if bibtex-align-at-equal-sign |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3194 (indent-to-column (- bibtex-text-indentation 2)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3195 (insert " ")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3196 (search-forward "=") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3197 (delete-horizontal-space) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3198 (if bibtex-align-at-equal-sign |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3199 (insert " ") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3200 (indent-to-column bibtex-text-indentation)))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3201 (bibtex-inside-field))) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3202 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3203 (defun bibtex-remove-delimiters () |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3204 "Remove \"\" or {} around string." |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3205 (interactive) |
27701
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
3206 (save-excursion |
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
3207 (bibtex-inside-field) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3208 (let ((bounds (bibtex-enclosing-field))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3209 (goto-char (bibtex-start-of-text-in-field bounds)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3210 (delete-char 1) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3211 (goto-char (1- (bibtex-end-of-text-in-field bounds))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3212 (delete-backward-char 1)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3213 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3214 (defun bibtex-kill-field (&optional copy-only) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3215 "Kill the entire enclosing BibTeX field. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3216 With prefix arg COPY-ONLY, copy the current field to `bibtex-field-kill-ring', |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3217 but do not actually kill it." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3218 (interactive "P") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3219 (save-excursion |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3220 (bibtex-inside-field) |
27701
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
3221 (let* ((case-fold-search t) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3222 (bounds (bibtex-enclosing-field)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3223 (end (bibtex-end-of-field bounds)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3224 (beg (bibtex-start-of-field bounds))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3225 (goto-char end) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3226 (skip-chars-forward " \t\n,") |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3227 (push (list 'field (bibtex-name-in-field bounds) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3228 (bibtex-text-in-field-bounds bounds)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3229 bibtex-field-kill-ring) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3230 (if (> (length bibtex-field-kill-ring) bibtex-field-kill-ring-max) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3231 (setcdr (nthcdr (1- bibtex-field-kill-ring-max) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3232 bibtex-field-kill-ring) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3233 nil)) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3234 (setq bibtex-field-kill-ring-yank-pointer bibtex-field-kill-ring) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3235 (unless copy-only |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3236 (delete-region beg end)))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3237 (setq bibtex-last-kill-command 'field)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3238 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3239 (defun bibtex-copy-field-as-kill () |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3240 (interactive) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3241 (bibtex-kill-field t)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3242 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3243 (defun bibtex-kill-entry (&optional copy-only) |
27701
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
3244 "Kill the entire enclosing BibTeX entry. |
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
3245 With prefix arg COPY-ONLY the current entry to |
19461 | 3246 `bibtex-entry-kill-ring', but do not actually kill it." |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3247 (interactive "P") |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3248 (save-excursion |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3249 (let* ((case-fold-search t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3250 (beg (bibtex-beginning-of-entry)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3251 (end (progn (bibtex-end-of-entry) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3252 (if (re-search-forward |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3253 bibtex-entry-maybe-empty-head nil 'move) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3254 (goto-char (match-beginning 0))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3255 (point)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3256 (push (list 'entry (buffer-substring-no-properties beg end)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3257 bibtex-entry-kill-ring) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3258 (if (> (length bibtex-entry-kill-ring) bibtex-entry-kill-ring-max) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3259 (setcdr (nthcdr (1- bibtex-entry-kill-ring-max) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3260 bibtex-entry-kill-ring) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3261 nil)) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3262 (setq bibtex-entry-kill-ring-yank-pointer bibtex-entry-kill-ring) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3263 (unless copy-only |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3264 (delete-region beg end)))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3265 (setq bibtex-last-kill-command 'entry)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3266 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3267 (defun bibtex-copy-entry-as-kill () |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3268 (interactive) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3269 (bibtex-kill-entry t)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3270 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3271 (defun bibtex-yank (&optional n) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3272 "Reinsert the last BibTeX item. |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3273 More precisely, reinsert the field or entry killed or yanked most recently. |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3274 With argument N, reinsert the Nth most recently killed BibTeX item. |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3275 See also the command \\[bibtex-yank-pop]]." |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3276 (interactive "*p") |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3277 (bibtex-insert-current-kill (1- n)) |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
3278 (setq this-command 'bibtex-yank)) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3279 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3280 (defun bibtex-yank-pop (n) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3281 "Replace just-yanked killed BibTeX item with a different. |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3282 This command is allowed only immediately after a `bibtex-yank' or a |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3283 `bibtex-yank-pop'. |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3284 At such a time, the region contains a reinserted previously killed |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
3285 BibTeX item. `bibtex-yank-pop' deletes that item and inserts in its |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3286 place a different killed BibTeX item. |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3287 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3288 With no argument, the previous kill is inserted. |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3289 With argument N, insert the Nth previous kill. |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3290 If N is negative, this is a more recent kill. |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3291 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3292 The sequence of kills wraps around, so that after the oldest one |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3293 comes the newest one." |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3294 (interactive "*p") |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3295 (if (not (eq last-command 'bibtex-yank)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3296 (error "Previous command was not a BibTeX yank")) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3297 (setq this-command 'bibtex-yank) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3298 (let ((inhibit-read-only t)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3299 (delete-region (point) (mark t)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3300 (bibtex-insert-current-kill n))) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3301 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3302 (defun bibtex-empty-field () |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3303 "Delete the text part of the current field, replace with empty text." |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3304 (interactive) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3305 (bibtex-inside-field) |
27701
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
3306 (let ((bounds (bibtex-enclosing-field))) |
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
3307 (goto-char (bibtex-start-of-text-in-field bounds)) |
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
3308 (delete-region (point) (bibtex-end-of-text-in-field bounds)) |
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
3309 (insert (concat (bibtex-field-left-delimiter) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3310 (bibtex-field-right-delimiter)) ) |
27701
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
3311 (bibtex-find-text t))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3312 |
14789
d68b71228abd
(bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents:
14410
diff
changeset
|
3313 (defun bibtex-pop-previous (arg) |
19461 | 3314 "Replace text of current field with the similar field in previous entry. |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
3315 With arg, goes up ARG entries. Repeated, goes up so many times. May be |
14789
d68b71228abd
(bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents:
14410
diff
changeset
|
3316 intermixed with \\[bibtex-pop-next] (bibtex-pop-next)." |
d68b71228abd
(bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents:
14410
diff
changeset
|
3317 (interactive "p") |
d68b71228abd
(bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents:
14410
diff
changeset
|
3318 (bibtex-pop arg 'previous)) |
257 | 3319 |
3320 (defun bibtex-pop-next (arg) | |
3321 "Replace text of current field with the text of similar field in next entry. | |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
3322 With arg, goes down ARG entries. Repeated, goes down so many times. May be |
257 | 3323 intermixed with \\[bibtex-pop-previous] (bibtex-pop-previous)." |
3324 (interactive "p") | |
14789
d68b71228abd
(bibtex-pop): New generic function which unifies the
Richard M. Stallman <rms@gnu.org>
parents:
14410
diff
changeset
|
3325 (bibtex-pop arg 'next)) |
257 | 3326 |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3327 (defun bibtex-clean-entry (&optional new-key called-by-reformat) |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3328 "Finish editing the current BibTeX entry and clean it up. |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3329 Checks that no required fields are empty and formats entry dependent |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3330 on the value of `bibtex-entry-format'. |
27701
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
3331 If the reference key of the entry is empty or a prefix argument is given, |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3332 calculate a new reference key. (Note: this only will work if fields in entry |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3333 begin on separate lines prior to calling `bibtex-clean-entry' or if |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3334 'realign is contained in `bibtex-entry-format'.) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3335 Don't call this on @String or @Preamble entries. |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3336 At end of the cleaning process, the functions in |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3337 `bibtex-clean-entry-hook' are called with region narrowed to entry." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3338 ;; Opt. arg called-by-reformat is t if bibtex-clean-entry |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3339 ;; is called by bibtex-reformat |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3340 (interactive "P") |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3341 (bibtex-format-entry) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3342 (let ((case-fold-search t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3343 key) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3344 (bibtex-beginning-of-entry) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3345 (setq key (save-excursion |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3346 (if (re-search-forward bibtex-entry-maybe-empty-head nil t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3347 (bibtex-key-in-head)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3348 (when (or new-key (not key)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3349 (setq key (if bibtex-autokey-edit-before-use |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3350 (read-from-minibuffer |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3351 "Key to use: " (bibtex-generate-autokey) nil nil |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3352 'bibtex-key-history) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3353 (bibtex-generate-autokey))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3354 (bibtex-beginning-of-entry) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3355 (re-search-forward bibtex-entry-maybe-empty-head) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3356 (if (match-beginning bibtex-key-in-head) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3357 (delete-region (match-beginning bibtex-key-in-head) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3358 (match-end bibtex-key-in-head))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3359 (insert key)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3360 (let* ((start (bibtex-beginning-of-entry)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3361 (end (progn (bibtex-end-of-entry) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3362 (if (re-search-forward |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3363 bibtex-entry-maybe-empty-head nil 'move) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3364 (goto-char (match-beginning 0))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3365 (point))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3366 (entry (buffer-substring start end)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3367 (index (progn (goto-char start) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3368 (bibtex-entry-index)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3369 (delete-region start end) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3370 (unless (prog1 (or called-by-reformat |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3371 (if bibtex-maintain-sorted-entries |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3372 (bibtex-prepare-new-entry index) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3373 (not (bibtex-find-entry (car index))))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3374 (insert entry) |
13728
4b7903cfa7ee
(bibtex-auto-fill-function): Adapted for use with
Karl Heuer <kwzh@gnu.org>
parents:
12770
diff
changeset
|
3375 (forward-char -1) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3376 (bibtex-beginning-of-entry) ; moves backward |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3377 (re-search-forward bibtex-entry-head)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3378 (error "New inserted entry yields duplicate key"))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3379 (unless called-by-reformat |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3380 (save-excursion |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3381 (save-restriction |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3382 (bibtex-narrow-to-entry) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3383 ;; Only update the list of keys if it's been built already. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3384 (if (consp bibtex-reference-keys) (bibtex-parse-keys t nil)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3385 (run-hooks 'bibtex-clean-entry-hook)))))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3386 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3387 (defun bibtex-fill-entry () |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3388 "Fill current BibTeX entry. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3389 Realign entry, so that every field starts on a separate line. Field |
19461 | 3390 names appear in column `bibtex-field-indentation', field text starts in |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
3391 column `bibtex-text-indentation' and continuation lines start here, too. |
19461 | 3392 If `bibtex-align-at-equal-sign' is non-nil, align equal signs also." |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3393 (interactive "*") |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3394 (let ((pnt (copy-marker (point))) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3395 (end (copy-marker (bibtex-end-of-entry))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3396 bounds) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3397 (bibtex-beginning-of-entry) |
18247
ae094c1a4334
(bibtex-delete-whitespace, bibtex-current-line)
Richard M. Stallman <rms@gnu.org>
parents:
18212
diff
changeset
|
3398 (bibtex-delete-whitespace) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3399 (indent-to-column bibtex-entry-offset) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3400 (while (setq bounds (bibtex-search-forward-field bibtex-field-name end)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3401 (let* ((begin-field (copy-marker (bibtex-start-of-field bounds))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3402 (end-field (copy-marker (bibtex-end-of-field bounds)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3403 (goto-char begin-field) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3404 (forward-char) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3405 (bibtex-delete-whitespace) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3406 (open-line 1) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3407 (forward-char) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3408 (indent-to-column (+ bibtex-entry-offset |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3409 bibtex-field-indentation)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3410 (re-search-forward "[ \t\n]*=" end) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3411 (replace-match "=") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3412 (forward-char -1) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3413 (if bibtex-align-at-equal-sign |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3414 (indent-to-column |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3415 (+ bibtex-entry-offset (- bibtex-text-indentation 2))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3416 (insert " ")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3417 (forward-char) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3418 (bibtex-delete-whitespace) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3419 (if bibtex-align-at-equal-sign |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3420 (insert " ") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3421 (indent-to-column bibtex-text-indentation)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3422 (while (re-search-forward "[ \t\n]+" end-field 'move) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3423 (replace-match " ")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3424 (do-auto-fill) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3425 (goto-char end-field))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3426 (if (looking-at ",") |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3427 (forward-char)) |
18247
ae094c1a4334
(bibtex-delete-whitespace, bibtex-current-line)
Richard M. Stallman <rms@gnu.org>
parents:
18212
diff
changeset
|
3428 (bibtex-delete-whitespace) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3429 (open-line 1) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3430 (forward-char) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3431 (indent-to-column bibtex-entry-offset) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3432 (goto-char pnt))) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3433 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3434 (defun bibtex-reformat (&optional additional-options called-by-convert-alien) |
19461 | 3435 "Reformat all BibTeX entries in buffer or region. |
3436 With prefix argument, read options for reformatting from minibuffer. | |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
3437 With \\[universal-argument] \\[universal-argument] prefix argument, reuse previous answers (if any) again. |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3438 If mark is active it reformats entries in region, if not in whole buffer." |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3439 (interactive "*P") |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3440 (let* ((pnt (point)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3441 (use-previous-options |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3442 (and (equal (prefix-numeric-value additional-options) 16) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3443 (or bibtex-reformat-previous-options |
27701
5e135f0faf1d
(bibtex-mode): Replaced manual splitting of path
Gerd Moellmann <gerd@gnu.org>
parents:
26711
diff
changeset
|
3444 bibtex-reformat-previous-reference-keys))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3445 (bibtex-entry-format |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3446 (if additional-options |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3447 (if use-previous-options |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3448 bibtex-reformat-previous-options |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3449 (setq bibtex-reformat-previous-options |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3450 (delq nil (list |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3451 (if (or called-by-convert-alien |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3452 (y-or-n-p "Realign entries (recommended)? ")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3453 'realign) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3454 (if (y-or-n-p "Remove empty optional and alternative fields? ") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3455 'opts-or-alts) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3456 (if (y-or-n-p "Remove delimiters around pure numerical fields? ") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3457 'numerical-fields) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3458 (if (y-or-n-p (concat (if bibtex-comma-after-last-field "Insert" "Remove") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3459 " comma at end of entry? ")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3460 'last-comma) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3461 (if (y-or-n-p "Replace double page dashes by single ones? ") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3462 'page-dashes) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3463 (if (y-or-n-p "Force delimiters? ") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3464 'delimiters) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3465 (if (y-or-n-p "Unify case of entry types and field names? ") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3466 'unify-case))))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3467 '(realign))) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3468 (reformat-reference-keys (if additional-options |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3469 (if use-previous-options |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3470 bibtex-reformat-previous-reference-keys |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3471 (setq bibtex-reformat-previous-reference-keys |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3472 (y-or-n-p "Generate new reference keys automatically? "))))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3473 bibtex-autokey-edit-before-use |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3474 (bibtex-sort-ignore-string-entries t) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3475 (start-point (if (bibtex-mark-active) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3476 (region-beginning) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3477 (bibtex-beginning-of-first-entry) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3478 (bibtex-skip-to-valid-entry) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3479 (point))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3480 (end-point (if (bibtex-mark-active) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3481 (region-end) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3482 (point-max)))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3483 (save-restriction |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3484 (narrow-to-region start-point end-point) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3485 (when (memq 'realign bibtex-entry-format) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3486 (goto-char (point-min)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3487 (while (re-search-forward bibtex-valid-entry-whitespace-re nil t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3488 (replace-match "\n\\1"))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3489 (goto-char start-point) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3490 (bibtex-progress-message "Formatting" 1) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3491 (bibtex-map-entries (lambda (current) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3492 (bibtex-progress-message) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3493 (bibtex-clean-entry reformat-reference-keys t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3494 (when (memq 'realign bibtex-entry-format) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3495 (bibtex-end-of-entry) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3496 (bibtex-delete-whitespace) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3497 (open-line 2)))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3498 (bibtex-progress-message 'done)) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3499 (when (and reformat-reference-keys |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3500 bibtex-maintain-sorted-entries |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3501 (not called-by-convert-alien)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3502 (bibtex-sort-buffer) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3503 (setq bibtex-reference-keys nil) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3504 (bibtex-parse-keys nil t t)) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3505 (goto-char pnt))) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3506 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3507 (defun bibtex-convert-alien (&optional do-additional-reformatting) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3508 "Convert an alien BibTeX buffer to be fully usable by BibTeX mode. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3509 If a file does not conform with some standards used by BibTeX mode, |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3510 some of the high-level features of BibTeX mode will not be available. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3511 This function tries to convert current buffer to conform with these standards. |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3512 With prefix argument DO-ADDITIONAL-REFORMATTING |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3513 non-nil, read options for reformatting entries from minibuffer." |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3514 (interactive "*P") |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3515 (message "Starting to validate buffer...") |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3516 (sit-for 1 nil t) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3517 (goto-char (point-min)) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3518 (while (re-search-forward "[ \t\n]+@" nil t) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3519 (replace-match "\n@")) |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3520 (message |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3521 "If errors occur, correct them and call `bibtex-convert-alien' again") |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3522 (sit-for 5 nil t) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3523 (deactivate-mark) ; So bibtex-validate works on the whole buffer. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3524 (when (let (bibtex-maintain-sorted-entries) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3525 (bibtex-validate)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3526 (message "Starting to reformat entries...") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3527 (sit-for 2 nil t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3528 (bibtex-reformat do-additional-reformatting t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3529 (when bibtex-maintain-sorted-entries |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3530 (message "Starting to sort buffer...") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3531 (bibtex-sort-buffer)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3532 (goto-char (point-max)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3533 (message "Buffer is now parsable. Please save it."))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3534 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3535 (defun bibtex-complete () |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3536 "Complete word fragment before point according to context. |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3537 If inside key or crossref field complete key based on |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3538 `bibtex-reference-keys'. Inside any other field perform string |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3539 completion based on `bibtex-strings'. An error is signaled if point |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3540 is outside key or BibTeX field." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3541 (interactive) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3542 (let* ((pnt (point)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3543 (case-fold-search t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3544 bounds compl) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3545 (save-excursion |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3546 (if (and (setq bounds (bibtex-enclosing-field t)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3547 (>= pnt (bibtex-start-of-text-in-field bounds)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3548 (<= pnt (bibtex-end-of-text-in-field bounds))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3549 (progn |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3550 (goto-char (bibtex-start-of-name-in-field bounds)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3551 (setq compl (if (string= "crossref" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3552 (downcase |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3553 (buffer-substring-no-properties |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3554 (if (looking-at "\\(OPT\\)\\|\\(ALT\\)") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3555 (match-end 0) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3556 (point)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3557 (bibtex-end-of-name-in-field bounds)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3558 'key |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3559 'str))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3560 (bibtex-beginning-of-entry) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3561 (if (and (re-search-forward bibtex-entry-maybe-empty-head nil t) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3562 ;; point is inside a key |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3563 (or (and (match-beginning bibtex-key-in-head) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3564 (>= pnt (match-beginning bibtex-key-in-head)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3565 (<= pnt (match-end bibtex-key-in-head))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3566 ;; or point is on empty key |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3567 (and (not (match-beginning bibtex-key-in-head)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3568 (= pnt (match-end 0))))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3569 (setq compl 'key)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3570 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3571 (cond ((equal compl 'key) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3572 ;; key completion |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3573 (unless (consp bibtex-reference-keys) (bibtex-parse-keys nil t)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3574 (setq choose-completion-string-functions |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3575 (lambda (choice buffer mini-p base-size) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3576 (bibtex-choose-completion-string choice buffer mini-p base-size) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3577 (if bibtex-complete-key-cleanup |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3578 (funcall bibtex-complete-key-cleanup choice)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3579 ;; return t (required by choose-completion-string-functions) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3580 t)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3581 (let ((choice (bibtex-complete-internal bibtex-reference-keys))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3582 (if bibtex-complete-key-cleanup |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3583 (funcall bibtex-complete-key-cleanup choice)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3584 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3585 ((equal compl 'str) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3586 ;; string completion |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3587 (setq choose-completion-string-functions |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3588 (lambda (choice buffer mini-p base-size) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3589 (bibtex-choose-completion-string choice buffer mini-p base-size) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3590 (bibtex-complete-string-cleanup choice) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3591 ;; return t (required by choose-completion-string-functions) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3592 t)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3593 (bibtex-complete-string-cleanup (bibtex-complete-internal bibtex-strings))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3594 |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3595 (t (error "Point outside key or BibTeX field"))))) |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3596 |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3597 (defun bibtex-Article () |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
3598 "Insert a new BibTeX @Article entry; see also `bibtex-entry'." |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3599 (interactive "*") |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3600 (bibtex-entry "Article")) |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3601 |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3602 (defun bibtex-Book () |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
3603 "Insert a new BibTeX @Book entry; see also `bibtex-entry'." |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3604 (interactive "*") |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3605 (bibtex-entry "Book")) |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3606 |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3607 (defun bibtex-Booklet () |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
3608 "Insert a new BibTeX @Booklet entry; see also `bibtex-entry'." |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3609 (interactive "*") |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3610 (bibtex-entry "Booklet")) |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3611 |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3612 (defun bibtex-InBook () |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
3613 "Insert a new BibTeX @InBook entry; see also `bibtex-entry'." |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3614 (interactive "*") |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3615 (bibtex-entry "InBook")) |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3616 |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3617 (defun bibtex-InCollection () |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
3618 "Insert a new BibTeX @InCollection entry; see also `bibtex-entry'." |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3619 (interactive "*") |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3620 (bibtex-entry "InCollection")) |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3621 |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3622 (defun bibtex-InProceedings () |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
3623 "Insert a new BibTeX @InProceedings entry; see also `bibtex-entry'." |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3624 (interactive "*") |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3625 (bibtex-entry "InProceedings")) |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3626 |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3627 (defun bibtex-Manual () |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
3628 "Insert a new BibTeX @Manual entry; see also `bibtex-entry'." |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3629 (interactive "*") |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3630 (bibtex-entry "Manual")) |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3631 |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3632 (defun bibtex-MastersThesis () |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
3633 "Insert a new BibTeX @MastersThesis entry; see also `bibtex-entry'." |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3634 (interactive "*") |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3635 (bibtex-entry "MastersThesis")) |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3636 |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3637 (defun bibtex-Misc () |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
3638 "Insert a new BibTeX @Misc entry; see also `bibtex-entry'." |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3639 (interactive "*") |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3640 (bibtex-entry "Misc")) |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3641 |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3642 (defun bibtex-PhdThesis () |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
3643 "Insert a new BibTeX @PhdThesis entry; see also `bibtex-entry'." |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3644 (interactive "*") |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3645 (bibtex-entry "PhdThesis")) |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3646 |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3647 (defun bibtex-Proceedings () |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
3648 "Insert a new BibTeX @Proceedings entry; see also `bibtex-entry'." |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3649 (interactive "*") |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3650 (bibtex-entry "Proceedings")) |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3651 |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3652 (defun bibtex-TechReport () |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
3653 "Insert a new BibTeX @TechReport entry; see also `bibtex-entry'." |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3654 (interactive "*") |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3655 (bibtex-entry "TechReport")) |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3656 |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3657 (defun bibtex-Unpublished () |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
3658 "Insert a new BibTeX @Unpublished entry; see also `bibtex-entry'." |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3659 (interactive "*") |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3660 (bibtex-entry "Unpublished")) |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3661 |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3662 (defun bibtex-String (&optional key) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3663 "Insert a new BibTeX @String entry with key KEY." |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3664 (interactive |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3665 (progn (unless (consp bibtex-reference-keys) (bibtex-parse-keys nil t)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3666 (list (completing-read "String key: " bibtex-reference-keys |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3667 nil nil nil 'bibtex-key-history)))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3668 ;; If we want to sort String entries only the sorting scheme |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3669 ;; entry-class is meaningful |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3670 (let ((bibtex-maintain-sorted-entries |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3671 (if (and (not bibtex-sort-ignore-string-entries) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3672 bibtex-maintain-sorted-entries) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3673 'entry-class)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3674 endpos) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3675 (unless (bibtex-prepare-new-entry (list key nil "String")) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3676 (error "Entry with key `%s' already exists" key)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3677 (if (zerop (length key)) (setq key nil)) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3678 (indent-to-column bibtex-entry-offset) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3679 (insert "@String" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3680 (bibtex-entry-left-delimiter)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3681 (if key |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3682 (insert key) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3683 (setq endpos (point))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3684 (insert " = " |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3685 (bibtex-field-left-delimiter)) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3686 (if key |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3687 (setq endpos (point))) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3688 (insert (bibtex-field-right-delimiter) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3689 (bibtex-entry-right-delimiter) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3690 "\n") |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3691 (goto-char endpos))) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3692 |
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3693 (defun bibtex-Preamble () |
22563
2e2a71dfec63
Numerous documentation fixups.
Richard M. Stallman <rms@gnu.org>
parents:
21169
diff
changeset
|
3694 "Insert a new BibTeX @Preamble entry." |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3695 (interactive "*") |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3696 (bibtex-move-outside-of-entry) |
18212
3864648e9b4f
(bibtex-mode-map): Changed the binding of the C-TAB
Richard M. Stallman <rms@gnu.org>
parents:
17700
diff
changeset
|
3697 (indent-to-column bibtex-entry-offset) |
51415
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3698 (insert "@Preamble" |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3699 (bibtex-entry-left-delimiter) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3700 (bibtex-entry-right-delimiter) |
762217a72cae
Long overdue merge.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49599
diff
changeset
|
3701 "\n") |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3702 (forward-line -1) |
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3703 (forward-char 10)) |
257 | 3704 |
3705 | |
12700
b3a8ee2da96a
Add keywords and comments as per conventions.
Richard M. Stallman <rms@gnu.org>
parents:
12028
diff
changeset
|
3706 ;; Make BibTeX a Feature |
257 | 3707 |
10219
d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
Richard M. Stallman <rms@gnu.org>
parents:
10106
diff
changeset
|
3708 (provide 'bibtex) |
2602
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
3709 |
2465861025cd
Installed Aaron Larson's new bibtex.el. See the header comment for
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
3710 ;;; bibtex.el ends here |