aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorMiles Bader2004-09-15 09:00:10 +0000
committerMiles Bader2004-09-15 09:00:10 +0000
commita63aa6924c6a4bb92dfdb524627c13c791615e2b (patch)
tree771f503928d8f4486f462405107334910302e3ad /lisp
parenta88eb4ae4abf8cf3f83ecd4ad08e86db7345ae22 (diff)
parent5c2137b83cb6cf1ffc32e26ff091cf1785a9bf1a (diff)
downloademacs-a63aa6924c6a4bb92dfdb524627c13c791615e2b.tar.gz
emacs-a63aa6924c6a4bb92dfdb524627c13c791615e2b.zip
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-40
Merge from emacs--cvs-trunk--0 Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-535 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-536 sync-tree with gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-537 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-538 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-539 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-540 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-541 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-542 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-545 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-546 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-547 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-548 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-549 Use symbol-matching for generic-mode keywords * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-550 Update from CVS * miles@gnu.org--gnu-2004/gnus--devo--0--patch-2 Add {arch}/=cvs-sync-make-log * miles@gnu.org--gnu-2004/gnus--rel--5.8--base-0 Import from Gnus CVS branch V5-8 * miles@gnu.org--gnu-2004/gnus--rel--5.8--patch-1 {arch}/=tagging-method: Add CVS and autoconf grot to junk regexp * miles@gnu.org--gnu-2004/gnus--rel--5.8--patch-2 Use explicit tags for autoconf input files * miles@gnu.org--gnu-2004/gnus--rel--5.8--patch-3 Remove RCS keywords * miles@gnu.org--gnu-2004/gnus--rel--5.8--patch-4 Fix copied explicit id-tags * miles@gnu.org--gnu-2004/gnus--rel--5.8--patch-5 Add {arch}/=cvs-sync-make-log * miles@gnu.org--gnu-2004/gnus--rel--5.8--patch-6 configure.in: Use ifelse instead of m4_if for arch-tag: comment * miles@gnu.org--gnu-2004/gnus--rel--5.10--base-0 tag of miles@gnu.org--gnu-2004/gnus--rel--5.8--base-0 * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-1 Gnus 5.10, from CVS branch v5-10 * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-2 Merge from gnus--rel--5.8 * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-3 Use explicit tags for autoconf input files * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-4 sync-tree with gnus--rel--5.8 * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-5 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-6 Merge from gnus--rel--5.8 * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-7 Remove RCS keywords * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-8 Merge from gnus--rel--5.8 * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-9 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-10 Add {arch}/=cvs-sync-make-log * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-11 Merge from gnus--rel--5.8 * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-12 Update from CVS: make.bat: Fix line endings around arch-tag. * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-13 - miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-17 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-21 Merge from emacs--cvs-trunk--0 * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-22 Update from CVS: lisp/nndb.el (require): Remove tcp and duplicate cl. * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-23 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-24 lisp/nnimap.el (nnimap-open-connection): Remove extraneous end-paren * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-25 - miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-26 Update from CVS
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog184
-rw-r--r--lisp/ChangeLog.104
-rw-r--r--lisp/desktop.el168
-rw-r--r--lisp/emacs-lisp/checkdoc.el5
-rw-r--r--lisp/emulation/cua-rect.el3
-rw-r--r--lisp/faces.el4
-rw-r--r--lisp/files.el1
-rw-r--r--lisp/generic.el4
-rw-r--r--lisp/gnus/ChangeLog30
-rw-r--r--lisp/gnus/ChangeLog.216
-rw-r--r--lisp/gnus/gnus-registry.el26
-rw-r--r--lisp/gnus/gnus-sum.el4
-rw-r--r--lisp/gnus/nndb.el8
-rw-r--r--lisp/gnus/nnimap.el7
-rw-r--r--lisp/ibuf-ext.el5
-rw-r--r--lisp/ido.el25
-rw-r--r--lisp/isearch.el8
-rw-r--r--lisp/kmacro.el50
-rw-r--r--lisp/novice.el6
-rw-r--r--lisp/progmodes/compile.el53
-rw-r--r--lisp/progmodes/grep.el13
-rw-r--r--lisp/simple.el3
-rw-r--r--lisp/textmodes/bibtex.el748
-rw-r--r--lisp/textmodes/dns-mode.el198
-rw-r--r--lisp/vc-arch.el32
-rw-r--r--lisp/vc-hooks.el38
-rw-r--r--lisp/vc-mcvs.el32
-rw-r--r--lisp/windmove.el70
28 files changed, 1146 insertions, 599 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 0d9e7b45e24..6edfb468241 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,4 +1,154 @@
12004-09-08 Stefan <monnier@iro.umontreal.ca> 12004-09-15 Miles Bader <miles@gnu.org>
2
3 * generic.el (generic-make-keywords-list): Use symbol rather than
4 word anchors in regexp.
5
62004-09-14 Sean O'Rourke <sorourke@cs.ucsd.edu>
7
8 * ibuf-ext.el (define-ibuffer-filter filename): If buffer has
9 no file name consider `dired-directory'.
10
112004-09-14 Kim F. Storm <storm@cua.dk>
12
13 * faces.el (cursor): Add face-no-inherit property. Doc fix.
14
152004-09-14 Simon Josefsson <jas@extundo.com>
16
17 * files.el (auto-mode-alist): Map .soa and .zone to dns-mode.
18
19 * textmodes/dns-mode.el: Add.
20
212004-09-13 Stefan Monnier <monnier@iro.umontreal.ca>
22
23 * novice.el (disabled-command-hook): Use shorthand for obsolescence.
24 (disabled-command-function): Make the ?\ char more obvious.
25
26 * vc-arch.el (vc-arch-root, vc-arch-registered):
27 * vc-mcvs.el (vc-mcvs-root, vc-mcvs-registered): Use vc-find-root.
28
292004-09-13 Hovav Shacham <hovav@sha1.stanford.edu>
30
31 * windmove.el (windmove-frame-edges): Report coordinates of
32 outside edges of frame, not inside edges.
33 (windmove-coordinates-of-position): Convert into wrapper to new
34 function `windmove-coordinates-of-window-position';
35 `compute-motion' always applies to selected window.
36 (windmove-coordinates-of-position): Update documentation to refer
37 to Emacs 21 Lisp Reference Manual.
38 (windmove-find-other-window): Fix off-by-one errors for max x,y.
39
402004-09-13 Kim F. Storm <storm@cua.dk>
41
42 * isearch.el (isearch-resume-in-command-history): Rename from
43 isearch-resume-enabled and change default to nil.
44
452004-09-12 Stefan Monnier <monnier@iro.umontreal.ca>
46
47 * vc-hooks.el (vc-ignore-dir-regexp): New var.
48 (vc-registered): Use it.
49 (vc-find-root): New fun.
50
51 * emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
52 Don't tell to use \\{...} when it's already done.
53
54 * textmodes/bibtex.el (bibtex-generate-url-list): Change format.
55 Provide a sample complex default.
56 (bibtex-url, bibtex-font-lock-url): Adapt to new format.
57 (bibtex-entry): Use mapc.
58
592004-09-12 Kim F. Storm <storm@cua.dk>
60
61 * kmacro.el (kmacro-step-edit-prompt): Add "%s" format to message.
62
63 * emulation/cua-rect.el (cua--rectangle-operation): Let bind
64 inhibit-field-text-motion to t so rectangles work in comint buffers.
65
66 * simple.el (choose-completion-string): Set buffer before running
67 choose-completion-string-functions hook so it can be buffer-local.
68
692004-09-12 Daniel Pfeiffer <occitan@esperanto.org>
70
71 * progmodes/compile.el (compilation-start): Parse command to see
72 if it starts with a cd, and if so perform it for the *compilation*
73 buffer. Change the header to reflect this.
74
752004-09-11 Kim F. Storm <storm@cua.dk>
76
77 * ido.el (ido-enable-dot-prefix): Doc fix.
78 (ido-enable-dot-prefix): New defcustom.
79 (ido-set-matches1): Use it.
80
812004-09-10 Stefan Monnier <monnier@iro.umontreal.ca>
82
83 * textmodes/bibtex.el (bibtex-mark-active)
84 (bibtex-run-with-idle-timer): Move the `if' inside the defun.
85
862004-09-10 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
87
88 * textmodes/bibtex.el (bibtex-autokey-titleword-ignore): Regexp is
89 used in a case insensitive environment.
90 (bibtex-mode-map): Rearrange order of menus.
91 (bibtex-quoted-string-re): Obsolete.
92 (bibtex-complete-key-cleanup): Variable replaced by new function.
93 (bibtex-font-lock-keywords): Use backquotes.
94 (bibtex-font-lock-url-regexp): New internal variable.
95 (bibtex-name-in-field): New optional arg remove-opt-alt to remove
96 "OPT" and "ALT".
97 (bibtex-insert-current-kill, bibtex-make-field)
98 (bibtex-prepare-new-entry, bibtex-yank-pop, bibtex-String): Use unless.
99 (bibtex-parse-field-text): Simplify.
100 (bibtex-string=): New helper function.
101 (bibtex-member-of-regexp): Merge with bibtex-autokey-get-title.
102 (bibtex-map-entries): Use bibtex-string=.
103 (bibtex-search-entry): Use not.
104 (bibtex-enclosing-field): Fix docstring.
105 (bibtex-assoc-regexp): Obsolete.
106 (bibtex-format-entry): Use assoc-string and bibtex-string=.
107 (bibtex-autokey-get-names): Handle empty name field.
108 (bibtex-parse-strings): Use assoc-string and unless.
109 (bibtex-complete-string-cleanup): Expansion list is passed as an arg.
110 Use assoc-string.
111 (bibtex-pop): Simplify.
112 (bibtex-mode): Set font-lock-extra-managed-props.
113 (bibtex-entry-update): Use assoc-string.
114 (bibtex-parse-entry): Remove "OPT" and "ALT" from FIELD.
115 (bibtex-autofill-entry): Use bibtex-string=.
116 (bibtex-print-help-message): Simplify.
117 (bibtex-find-entry): New optional arg START.
118 (bibtex-validate): Use bibtex-string= and assoc-string.
119 Do not call obsolete function compilation-parse-errors.
120 (bibtex-remove-delimiters): Only remove delimiters if present.
121 (bibtex-copy-entry-as-kill): Add docstring.
122 (bibtex-clean-entry): Use bibtex-string=. Handle empty keys.
123 Detect duplicate keys if bibtex-maintain-sorted-entries is nil.
124 (bibtex-complete): Use bibtex-predefined-month-strings,
125 bibtex-string=, and new function bibtex-complete-key-cleanup.
126 (bibtex-generate-url-list): New variable.
127 (bibtex-url): New command bound to C-c C-l and mouse-2.
128 (bibtex-url-map): New local keymap for bibtex-url-mouse.
129 (bibtex-font-lock-url): New function.
130
1312004-09-09 Stefan Monnier <monnier@iro.umontreal.ca>
132
133 * progmodes/grep.el (grep-mode): Remove unnecessary autoload.
134
1352004-09-09 Kim F. Storm <storm@cua.dk>
136
137 * kmacro.el (kmacro-bind-to-key): Associate dedicated macro
138 counter and format with binding.
139 (kmacro-name-last-macro): New defun. Like name-last-kbd-macro, but
140 the declared macro uses own macro counter and format. Give symbol
141 kmacro property.
142 (kmacro-keymap): Bind kmacro-name-last-macro to n.
143 (kmacro-start-macro, kmacro-end-macro, kmacro-call-macro)
144 (kmacro-end-and-call-macro): Doc fix.
145
1462004-09-09 Lars Hansen <larsh@math.ku.dk>
147
148 * desktop.el (desktop-clear-preserve-buffers):
149 Remove make-obsolete-variable.
150
1512004-09-08 Stefan Monnier <monnier@iro.umontreal.ca>
2 152
3 * vc-arch.el (vc-arch-state): Fix parsing for `names' method. 153 * vc-arch.el (vc-arch-state): Fix parsing for `names' method.
4 154
@@ -85,7 +235,7 @@
85 window system if overflow-newline-into-fringe is enabled. 235 window system if overflow-newline-into-fringe is enabled.
86 (term-mode): Don't disable overflow-newline-into-fringe. 236 (term-mode): Don't disable overflow-newline-into-fringe.
87 237
882004-09-07 Stefan <monnier@iro.umontreal.ca> 2382004-09-07 Stefan Monnier <monnier@iro.umontreal.ca>
89 239
90 * term/xterm.el (function-key-map): Add bindings for C- and S- cursor 240 * term/xterm.el (function-key-map): Add bindings for C- and S- cursor
91 motion as seen on my Mac OS X xterms. 241 motion as seen on my Mac OS X xterms.
@@ -342,8 +492,8 @@
342 492
3432004-08-29 Kim F. Storm <storm@cua.dk> 4932004-08-29 Kim F. Storm <storm@cua.dk>
344 494
345 * emulation/cua-base.el (cua-auto-expand-rectangles): Remove 495 * emulation/cua-base.el (cua-auto-expand-rectangles):
346 automatic rectangle padding feature; replace by non-destructive 496 Remove automatic rectangle padding feature; replace by non-destructive
347 virtual rectangle edges feature. 497 virtual rectangle edges feature.
348 (cua-virtual-rectangle-edges): New defcustom. 498 (cua-virtual-rectangle-edges): New defcustom.
349 (cua-auto-tabify-rectangles): New defcustom. 499 (cua-auto-tabify-rectangles): New defcustom.
@@ -826,8 +976,8 @@
826 key-translation-map. 976 key-translation-map.
827 (encoded-kbd-setup-keymap): Setup key-translation-map. 977 (encoded-kbd-setup-keymap): Setup key-translation-map.
828 (saved-key-translation-map): New variable. 978 (saved-key-translation-map): New variable.
829 (encoded-kbd-mode): Save/restore key-translation-map. Adjusted 979 (encoded-kbd-mode): Save/restore key-translation-map.
830 for the change of encoded-kbd-setup-keymap. 980 Adjust for the change of encoded-kbd-setup-keymap.
831 981
8322004-08-02 Kim F. Storm <storm@cua.dk> 9822004-08-02 Kim F. Storm <storm@cua.dk>
833 983
@@ -990,12 +1140,11 @@
990 1140
991 Sync with Tramp 2.0.43. 1141 Sync with Tramp 2.0.43.
992 1142
993 * net/tramp.el (tramp-handle-verify-visited-file-modtime): Remove 1143 * net/tramp.el (tramp-handle-verify-visited-file-modtime):
994 outdated comment. 1144 Remove outdated comment.
995 (tramp-locked, tramp-locker): New variables for implementing a 1145 (tramp-locked, tramp-locker): New variables for implementing a
996 global lock. 1146 global lock.
997 (tramp-sh-file-name-handler): Use them to implement the global 1147 (tramp-sh-file-name-handler): Use them to implement the global lock.
998 lock.
999 1148
10002004-07-13 Michael Albinus <michael.albinus@gmx.de> 11492004-07-13 Michael Albinus <michael.albinus@gmx.de>
1001 1150
@@ -1030,14 +1179,15 @@
1030 * emacs-lisp/testcover.el: New category "potentially-1valued" for 1179 * emacs-lisp/testcover.el: New category "potentially-1valued" for
1031 functions that are not erroneous if either 1-valued or 1180 functions that are not erroneous if either 1-valued or
1032 multi-valued. Detect functions in this class. 1181 multi-valued. Detect functions in this class.
1033 (testcover-1value-functions, testcover-compose-functions, 1182 (testcover-1value-functions, testcover-compose-functions)
1034 testcover-progn-functions) Added some additional functions to lists. 1183 (testcover-progn-functions) Added some additional functions to lists.
1035 (testcover-mark): Bugfix when marking up the definition for an 1184 (testcover-mark): Bugfix when marking up the definition for an
1036 empty function. 1185 empty function.
1037 1186
10382004-07-17 Richard M. Stallman <rms@gnu.org> 11872004-07-17 Richard M. Stallman <rms@gnu.org>
1039 1188
1040 * replace.el (occur-read-primary-args): Pass default to read-from-minibuffer. 1189 * replace.el (occur-read-primary-args): Pass default to
1190 read-from-minibuffer.
1041 1191
1042 * mail/footnote.el (footnote-section-tag): Use defcustom. 1192 * mail/footnote.el (footnote-section-tag): Use defcustom.
1043 1193
@@ -1146,8 +1296,8 @@
1146 1296
11472004-07-09 John Paul Wallington <jpw@gnu.org> 12972004-07-09 John Paul Wallington <jpw@gnu.org>
1148 1298
1149 * emacs-lisp/re-builder.el (reb-update-overlays): Distinguish 1299 * emacs-lisp/re-builder.el (reb-update-overlays):
1150 between one and several matches in message. 1300 Distinguish between one and several matches in message.
1151 1301
11522004-07-09 Richard M. Stallman <rms@gnu.org> 13022004-07-09 Richard M. Stallman <rms@gnu.org>
1153 1303
@@ -1185,11 +1335,11 @@
1185 Do not treat double clicks and triple clicks specially in the 1335 Do not treat double clicks and triple clicks specially in the
1186 scroll bar (preventing strange repositioning problems) 1336 scroll bar (preventing strange repositioning problems)
1187 1337
11882004-07-06 Stefan <monnier@iro.umontreal.ca> 13382004-07-06 Stefan Monnier <monnier@iro.umontreal.ca>
1189 1339
1190 * replace.el (query-replace-regexp-eval): Fix last change. 1340 * replace.el (query-replace-regexp-eval): Fix last change.
1191 1341
11922004-07-05 Stefan <monnier@iro.umontreal.ca> 13422004-07-05 Stefan Monnier <monnier@iro.umontreal.ca>
1193 1343
1194 * replace.el (query-replace-descr): New fun. 1344 * replace.el (query-replace-descr): New fun.
1195 (query-replace-read-from, query-replace-read-args): Default to the 1345 (query-replace-read-from, query-replace-read-args): Default to the
diff --git a/lisp/ChangeLog.10 b/lisp/ChangeLog.10
index cf1743c3490..486f0f38964 100644
--- a/lisp/ChangeLog.10
+++ b/lisp/ChangeLog.10
@@ -14327,7 +14327,7 @@
143272002-06-01 Kim F. Storm <storm@cua.dk> 143272002-06-01 Kim F. Storm <storm@cua.dk>
14328 14328
14329 * simple.el: Reworked previous change. 14329 * simple.el: Reworked previous change.
14330 (choose-completion-string1): Merged back into choose-completion-string. 14330 (choose-completion-string1): Merge back into choose-completion-string.
14331 (choose-completion-string): Run choose-completion-string-functions 14331 (choose-completion-string): Run choose-completion-string-functions
14332 after checking for proper minibuffer window. Added mini-p arg to 14332 after checking for proper minibuffer window. Added mini-p arg to
14333 the hook functions. Insert choice if all hook functions return nil. 14333 the hook functions. Insert choice if all hook functions return nil.
@@ -14348,7 +14348,7 @@
143482002-06-01 Kim F. Storm <storm@cua.dk> 143482002-06-01 Kim F. Storm <storm@cua.dk>
14349 14349
14350 * simple.el (choose-completion-string-functions): New special hook. 14350 * simple.el (choose-completion-string-functions): New special hook.
14351 (choose-completion-string1): Renamed from choose-completion-string. 14351 (choose-completion-string1): Rename from choose-completion-string.
14352 (choose-completion-string): Run choose-completion-string-functions 14352 (choose-completion-string): Run choose-completion-string-functions
14353 until success, and only call choose-completion-string1 if it fails. 14353 until success, and only call choose-completion-string1 if it fails.
14354 14354
diff --git a/lisp/desktop.el b/lisp/desktop.el
index a71fc6c79fe..28521a0d7c4 100644
--- a/lisp/desktop.el
+++ b/lisp/desktop.el
@@ -171,13 +171,13 @@ This is useful for truncating history lists, for example."
171 :type 'hook 171 :type 'hook
172 :group 'desktop) 172 :group 'desktop)
173 173
174(defcustom desktop-globals-to-save '( 174(defcustom desktop-globals-to-save
175 desktop-missing-file-warning 175 '(desktop-missing-file-warning
176 tags-file-name 176 tags-file-name
177 tags-table-list 177 tags-table-list
178 search-ring 178 search-ring
179 regexp-search-ring 179 regexp-search-ring
180 register-alist) 180 register-alist)
181 "List of global variables saved by `desktop-save'. 181 "List of global variables saved by `desktop-save'.
182An element may be variable name (a symbol) or a cons cell of the form 182An element may be variable name (a symbol) or a cons cell of the form
183\(VAR . MAX-SIZE), which means to truncate VAR's value to at most 183\(VAR . MAX-SIZE), which means to truncate VAR's value to at most
@@ -186,13 +186,13 @@ Feature: Saving `kill-ring' implies saving `kill-ring-yank-pointer'."
186 :type '(repeat (restricted-sexp :match-alternatives (symbolp consp))) 186 :type '(repeat (restricted-sexp :match-alternatives (symbolp consp)))
187 :group 'desktop) 187 :group 'desktop)
188 188
189(defcustom desktop-globals-to-clear '( 189(defcustom desktop-globals-to-clear
190 kill-ring 190 '(kill-ring
191 kill-ring-yank-pointer 191 kill-ring-yank-pointer
192 search-ring 192 search-ring
193 search-ring-yank-pointer 193 search-ring-yank-pointer
194 regexp-search-ring 194 regexp-search-ring
195 regexp-search-ring-yank-pointer) 195 regexp-search-ring-yank-pointer)
196 "List of global variables to clear by `desktop-clear'. 196 "List of global variables to clear by `desktop-clear'.
197An element may be variable name (a symbol) or a cons cell of the form 197An element may be variable name (a symbol) or a cons cell of the form
198\(VAR . FORM). Symbols are set to nil and for cons cells VAR is set 198\(VAR . FORM). Symbols are set to nil and for cons cells VAR is set
@@ -202,29 +202,27 @@ to the value obtained by evaluateing FORM."
202 202
203(defcustom desktop-clear-preserve-buffers-regexp 203(defcustom desktop-clear-preserve-buffers-regexp
204 "^\\(\\*scratch\\*\\|\\*Messages\\*\\|\\*tramp/.+\\*\\)$" 204 "^\\(\\*scratch\\*\\|\\*Messages\\*\\|\\*tramp/.+\\*\\)$"
205 "Regexp identifying buffers that `desktop-clear' should not delete." 205 "Regexp identifying buffers that `desktop-clear' should not delete.
206See also `desktop-clear-preserve-buffers'."
206 :type 'regexp 207 :type 'regexp
207 :group 'desktop) 208 :group 'desktop)
208 209
209;; Maintained for backward compatibility
210(defcustom desktop-clear-preserve-buffers nil 210(defcustom desktop-clear-preserve-buffers nil
211 "*List of buffer names that `desktop-clear' should not delete. 211 "*List of buffer names that `desktop-clear' should not delete.
212This variable is maintained for backward compatibility only." 212See also `desktop-clear-preserve-buffers-regexp'."
213 :type '(repeat string) 213 :type '(repeat string)
214 :group 'desktop) 214 :group 'desktop)
215(make-obsolete-variable 'desktop-clear-preserve-buffers 215
216 'desktop-clear-preserve-buffers-regexp) 216(defcustom desktop-locals-to-save
217 217 '(desktop-locals-to-save ; Itself! Think it over.
218(defcustom desktop-locals-to-save '( 218 truncate-lines
219 desktop-locals-to-save ; Itself! Think it over. 219 case-fold-search
220 truncate-lines 220 case-replace
221 case-fold-search 221 fill-column
222 case-replace 222 overwrite-mode
223 fill-column 223 change-log-default-name
224 overwrite-mode 224 line-number-mode
225 change-log-default-name 225 buffer-file-coding-system)
226 line-number-mode
227 buffer-file-coding-system)
228 "List of local variables to save for each buffer. 226 "List of local variables to save for each buffer.
229The variables are saved only when they really are local." 227The variables are saved only when they really are local."
230 :type '(repeat symbol) 228 :type '(repeat symbol)
@@ -282,11 +280,11 @@ DESKTOP-BUFFER-MISC.")
282(make-obsolete-variable 'desktop-buffer-misc-functions 280(make-obsolete-variable 'desktop-buffer-misc-functions
283 'desktop-save-buffer) 281 'desktop-save-buffer)
284 282
285(defcustom desktop-buffer-mode-handlers '( 283(defcustom desktop-buffer-mode-handlers
286 (dired-mode . dired-restore-desktop-buffer) 284 '((dired-mode . dired-restore-desktop-buffer)
287 (rmail-mode . rmail-restore-desktop-buffer) 285 (rmail-mode . rmail-restore-desktop-buffer)
288 (mh-folder-mode . mh-restore-desktop-buffer) 286 (mh-folder-mode . mh-restore-desktop-buffer)
289 (Info-mode . Info-restore-desktop-buffer)) 287 (Info-mode . Info-restore-desktop-buffer))
290 "Alist of major mode specific functions to restore a desktop buffer. 288 "Alist of major mode specific functions to restore a desktop buffer.
291Functions are called by `desktop-read'. List elements must have the form 289Functions are called by `desktop-read'. List elements must have the form
292\(MAJOR-MODE . RESTORE-BUFFER-FUNCTION). 290\(MAJOR-MODE . RESTORE-BUFFER-FUNCTION).
@@ -580,8 +578,7 @@ See also `desktop-base-file-name'."
580 (let ((filename (expand-file-name desktop-base-file-name dirname)) 578 (let ((filename (expand-file-name desktop-base-file-name dirname))
581 (info 579 (info
582 (mapcar 580 (mapcar
583 (function 581 #'(lambda (b)
584 (lambda (b)
585 (set-buffer b) 582 (set-buffer b)
586 (list 583 (list
587 (desktop-file-name (buffer-file-name) dirname) 584 (desktop-file-name (buffer-file-name) dirname)
@@ -618,7 +615,7 @@ See also `desktop-base-file-name'."
618 (when (member (car locals) loclist) 615 (when (member (car locals) loclist)
619 (setq ll (cons (car locals) ll))))) 616 (setq ll (cons (car locals) ll)))))
620 (setq locals (cdr locals))) 617 (setq locals (cdr locals)))
621 ll)))) 618 ll)))
622 (buffer-list))) 619 (buffer-list)))
623 (buf (get-buffer-create "*desktop*"))) 620 (buf (get-buffer-create "*desktop*")))
624 (set-buffer buf) 621 (set-buffer buf)
@@ -639,19 +636,15 @@ See also `desktop-base-file-name'."
639 " kill-ring))\n")) 636 " kill-ring))\n"))
640 637
641 (insert "\n;; Buffer section -- buffers listed in same order as in buffer list:\n") 638 (insert "\n;; Buffer section -- buffers listed in same order as in buffer list:\n")
642 (mapcar 639 (mapcar #'(lambda (l)
643 (function 640 (if (apply 'desktop-save-buffer-p l)
644 (lambda (l) 641 (progn
645 (if (apply 'desktop-save-buffer-p l) 642 (insert "(desktop-create-buffer " desktop-file-version)
646 (progn 643 (mapcar #'(lambda (e)
647 (insert "(desktop-create-buffer " desktop-file-version) 644 (insert "\n " (desktop-value-to-string e)))
648 (mapcar 645 l)
649 (function 646 (insert ")\n\n"))))
650 (lambda (e) 647 info)
651 (insert "\n " (desktop-value-to-string e))))
652 l)
653 (insert ")\n\n")))))
654 info)
655 (setq default-directory dirname) 648 (setq default-directory dirname)
656 (when (file-exists-p filename) (delete-file filename)) 649 (when (file-exists-p filename) (delete-file filename))
657 (let ((coding-system-for-write 'utf-8-emacs)) 650 (let ((coding-system-for-write 'utf-8-emacs))
@@ -816,18 +809,18 @@ directory DIRNAME."
816 (defvar desktop-first-buffer) ;; Dynamically bound in `desktop-read' 809 (defvar desktop-first-buffer) ;; Dynamically bound in `desktop-read'
817) 810)
818 811
819(defun desktop-create-buffer ( 812(defun desktop-create-buffer
820 desktop-file-version 813 (desktop-file-version
821 desktop-buffer-file-name 814 desktop-buffer-file-name
822 desktop-buffer-name 815 desktop-buffer-name
823 desktop-buffer-major-mode 816 desktop-buffer-major-mode
824 desktop-buffer-minor-modes 817 desktop-buffer-minor-modes
825 desktop-buffer-point 818 desktop-buffer-point
826 desktop-buffer-mark 819 desktop-buffer-mark
827 desktop-buffer-read-only 820 desktop-buffer-read-only
828 desktop-buffer-misc 821 desktop-buffer-misc
829 &optional 822 &optional
830 desktop-buffer-locals) 823 desktop-buffer-locals)
831 ;; Just to silence the byte compiler. Bound locally in `desktop-read'. 824 ;; Just to silence the byte compiler. Bound locally in `desktop-read'.
832 (eval-when-compile 825 (eval-when-compile
833 (defvar desktop-buffer-ok-count) 826 (defvar desktop-buffer-ok-count)
@@ -835,21 +828,21 @@ directory DIRNAME."
835 ;; To make desktop files with relative file names possible, we cannot 828 ;; To make desktop files with relative file names possible, we cannot
836 ;; allow `default-directory' to change. Therefore we save current buffer. 829 ;; allow `default-directory' to change. Therefore we save current buffer.
837 (save-current-buffer 830 (save-current-buffer
838 (let ( 831 (let ((buffer-list (buffer-list))
839 (buffer-list (buffer-list)) 832 (result
840 (result 833 (condition-case err
841 (condition-case err 834 (funcall (or (cdr (assq desktop-buffer-major-mode
842 (funcall (or (cdr (assq desktop-buffer-major-mode desktop-buffer-mode-handlers)) 835 desktop-buffer-mode-handlers))
843 'desktop-restore-file-buffer) 836 'desktop-restore-file-buffer)
844 desktop-buffer-file-name 837 desktop-buffer-file-name
845 desktop-buffer-name 838 desktop-buffer-name
846 desktop-buffer-misc) 839 desktop-buffer-misc)
847 (error 840 (error
848 (message "Desktop: Can't load buffer %s: %s" 841 (message "Desktop: Can't load buffer %s: %s"
849 desktop-buffer-name (error-message-string err)) 842 desktop-buffer-name
850 (when desktop-missing-file-warning (sit-for 1)) 843 (error-message-string err))
851 nil))) 844 (when desktop-missing-file-warning (sit-for 1))
852 ) 845 nil))))
853 (if (bufferp result) 846 (if (bufferp result)
854 (setq desktop-buffer-ok-count (1+ desktop-buffer-ok-count)) 847 (setq desktop-buffer-ok-count (1+ desktop-buffer-ok-count))
855 (setq desktop-buffer-fail-count (1+ desktop-buffer-fail-count)) 848 (setq desktop-buffer-fail-count (1+ desktop-buffer-fail-count))
@@ -867,17 +860,14 @@ directory DIRNAME."
867 (unless (equal (buffer-name) desktop-buffer-name) 860 (unless (equal (buffer-name) desktop-buffer-name)
868 (rename-buffer desktop-buffer-name)) 861 (rename-buffer desktop-buffer-name))
869 ;; minor modes 862 ;; minor modes
870 (cond ( 863 (cond ((equal '(t) desktop-buffer-minor-modes) ; backwards compatible
871 ;; backwards compatible 864 (auto-fill-mode 1))
872 (equal '(t) desktop-buffer-minor-modes) 865 ((equal '(nil) desktop-buffer-minor-modes) ; backwards compatible
873 (auto-fill-mode 1))( 866 (auto-fill-mode 0))
874 (equal '(nil) desktop-buffer-minor-modes) 867 (t
875 (auto-fill-mode 0))( 868 (mapcar #'(lambda (minor-mode)
876 t 869 (when (functionp minor-mode) (funcall minor-mode 1)))
877 (mapcar 870 desktop-buffer-minor-modes)))
878 #'(lambda (minor-mode)
879 (when (functionp minor-mode) (funcall minor-mode 1)))
880 desktop-buffer-minor-modes)))
881 ;; Even though point and mark are non-nil when written by `desktop-save' 871 ;; Even though point and mark are non-nil when written by `desktop-save'
882 ;; they may be modified by handlers wanting to set point or mark themselves. 872 ;; they may be modified by handlers wanting to set point or mark themselves.
883 (when desktop-buffer-point 873 (when desktop-buffer-point
diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el
index 2aba3ea254c..cc2be890657 100644
--- a/lisp/emacs-lisp/checkdoc.el
+++ b/lisp/emacs-lisp/checkdoc.el
@@ -1561,8 +1561,9 @@ mouse-[0-3]\\)\\)\\>"))
1561 ;; to describe the most important commands in your major mode, and 1561 ;; to describe the most important commands in your major mode, and
1562 ;; then use `\\{...}' to display the rest of the mode's keymap. 1562 ;; then use `\\{...}' to display the rest of the mode's keymap.
1563 (save-excursion 1563 (save-excursion
1564 (if (re-search-forward "\\\\\\\\\\[\\w+" e t 1564 (if (and (re-search-forward "\\\\\\\\\\[\\w+" e t
1565 (1+ checkdoc-max-keyref-before-warn)) 1565 (1+ checkdoc-max-keyref-before-warn))
1566 (not (re-search-forward "\\\\\\\\{\\w+}" e t)))
1566 (checkdoc-create-error 1567 (checkdoc-create-error
1567 "Too many occurrences of \\[function]. Use \\{keymap} instead" 1568 "Too many occurrences of \\[function]. Use \\{keymap} instead"
1568 s (marker-position e)))) 1569 s (marker-position e))))
diff --git a/lisp/emulation/cua-rect.el b/lisp/emulation/cua-rect.el
index 10d369fa042..742ae2033be 100644
--- a/lisp/emulation/cua-rect.el
+++ b/lisp/emulation/cua-rect.el
@@ -559,7 +559,8 @@ If command is repeated at same position, delete the rectangle."
559 ;; Rectangle is padded if PAD = t or numeric and (cua--rectangle-virtual-edges) 559 ;; Rectangle is padded if PAD = t or numeric and (cua--rectangle-virtual-edges)
560 ;; Perform auto-tabify after operation if TABIFY is non-nil. 560 ;; Perform auto-tabify after operation if TABIFY is non-nil.
561 ;; Mark is kept if keep-clear is 'keep and cleared if keep-clear is 'clear. 561 ;; Mark is kept if keep-clear is 'keep and cleared if keep-clear is 'clear.
562 (let* ((start (cua--rectangle-top)) 562 (let* ((inhibit-field-text-motion t)
563 (start (cua--rectangle-top))
563 (end (cua--rectangle-bot)) 564 (end (cua--rectangle-bot))
564 (l (cua--rectangle-left)) 565 (l (cua--rectangle-left))
565 (r (1+ (cua--rectangle-right))) 566 (r (1+ (cua--rectangle-right)))
diff --git a/lisp/faces.el b/lisp/faces.el
index 5ab91b5f1ba..8926bb2a65e 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -1925,11 +1925,13 @@ created."
1925 1925
1926 1926
1927(defface cursor '() 1927(defface cursor '()
1928 "Basic face for the cursor color under X." 1928 "Basic face for the cursor color under X.
1929Note: Other faces cannot inherit from the cursor face."
1929 :version "21.1" 1930 :version "21.1"
1930 :group 'cursor 1931 :group 'cursor
1931 :group 'basic-faces) 1932 :group 'basic-faces)
1932 1933
1934(put 'cursor 'face-no-inherit t)
1933 1935
1934(defface mouse '() 1936(defface mouse '()
1935 "Basic face for the mouse color under X." 1937 "Basic face for the mouse color under X."
diff --git a/lisp/files.el b/lisp/files.el
index 30f318fbf69..5571ede9d3e 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -1771,6 +1771,7 @@ in that case, this function acts as if `enable-local-variables' were t."
1771 ("\\.g\\'" . antlr-mode) 1771 ("\\.g\\'" . antlr-mode)
1772 ("\\.ses\\'" . ses-mode) 1772 ("\\.ses\\'" . ses-mode)
1773 ("\\.orig\\'" nil t) ; from patch 1773 ("\\.orig\\'" nil t) ; from patch
1774 ("\\.\\(soa\\|zone\\)\\'" . dns-mode)
1774 ("\\.in\\'" nil t))) 1775 ("\\.in\\'" nil t)))
1775 "Alist of filename patterns vs corresponding major mode functions. 1776 "Alist of filename patterns vs corresponding major mode functions.
1776Each element looks like (REGEXP . FUNCTION) or (REGEXP FUNCTION NON-NIL). 1777Each element looks like (REGEXP . FUNCTION) or (REGEXP FUNCTION NON-NIL).
diff --git a/lisp/generic.el b/lisp/generic.el
index a951a0d53d8..84cd4d0730f 100644
--- a/lisp/generic.el
+++ b/lisp/generic.el
@@ -405,10 +405,10 @@ INI file. This hook is NOT installed by default."
405The regexp is highlighted with FACE." 405The regexp is highlighted with FACE."
406 (unless (listp keywords-list) 406 (unless (listp keywords-list)
407 (error "Keywords argument must be a list of strings")) 407 (error "Keywords argument must be a list of strings"))
408 (list (concat prefix "\\<" 408 (list (concat prefix "\\_<"
409 ;; Use an optimized regexp. 409 ;; Use an optimized regexp.
410 (regexp-opt keywords-list t) 410 (regexp-opt keywords-list t)
411 "\\>" suffix) 411 "\\_>" suffix)
412 1 412 1
413 face)) 413 face))
414 414
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 0f0f4697c47..668607af94d 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,23 @@
12004-09-13 Reiner Steib <Reiner.Steib@gmx.de>
2
3 * gnus-sum.el (gnus-summary-copy-article): Fixed doc string.
4
52004-09-10 Miles Bader <miles@gnu.ai.mit.edu>
6
7 * nnimap.el (nnimap-open-connection): Remove extraneous end-paren.
8
92004-09-10 Teodor Zlatanov <tzz@lifelogs.com>
10
11 * nnimap.el (nnimap-open-connection): allow 'imaps' as a synonym
12 for the 'imap' port in netrc files
13
14 * gnus-registry.el (gnus-registry-trim): watch out for negatives
15 in gnus-registry-trim
16
172004-09-10 Simon Josefsson <jas@extundo.com>
18
19 * nndb.el (require): Remove tcp and duplicate cl.
20
12004-09-08 Reiner Steib <Reiner.Steib@gmx.de> 212004-09-08 Reiner Steib <Reiner.Steib@gmx.de>
2 22
3 * nntp.el (nntp): New customization group. 23 * nntp.el (nntp): New customization group.
@@ -388,12 +408,14 @@
388 * gnus-cus.el: Merged revisions 7.2 through 7.5 into branch to support 408 * gnus-cus.el: Merged revisions 7.2 through 7.5 into branch to support
389 gnus-agent.el update and incorporate bug fixes. 409 gnus-agent.el update and incorporate bug fixes.
390 410
391;; Local Variables: 411See ChangeLog.2 for earlier changes.
392;; coding: iso-2022-7bit
393;; End:
394 412
395 Copyright (C) 2002 2004 Free Software Foundation, Inc. 413 Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
396 Copying and distribution of this file, with or without modification, 414 Copying and distribution of this file, with or without modification,
397 are permitted provided the copyright notice and this notice are preserved. 415 are permitted provided the copyright notice and this notice are preserved.
398 416
417;; Local Variables:
418;; coding: iso-2022-7bit
419;; End:
420
399;;; arch-tag: 3f33a3e7-090d-492b-bedd-02a1417d32b4 421;;; arch-tag: 3f33a3e7-090d-492b-bedd-02a1417d32b4
diff --git a/lisp/gnus/ChangeLog.2 b/lisp/gnus/ChangeLog.2
index c36aad0a6e9..2dbd6d306dd 100644
--- a/lisp/gnus/ChangeLog.2
+++ b/lisp/gnus/ChangeLog.2
@@ -18913,12 +18913,18 @@
18913 * smime.el: New file. 18913 * smime.el: New file.
18914 * mml-smime.el: New file. 18914 * mml-smime.el: New file.
18915 18915
18916;; Local Variables: 189162000-10-27 19:42:12 ShengHuo ZHU <zsh@cs.rochester.edu>
18917;; coding: iso-2022-7bit 18917
18918;; End: 18918 * ChangeLog: Moved to ChangeLog.1.
18919
18920See ChangeLog.1 for earlier changes.
18919 18921
18920 Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. 18922 Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
18921 Copying and distribution of this file, with or without modification, 18923 Copying and distribution of this file, with or without modification,
18922 are permitted provided the copyright notice and this notice are preserved. 18924 are permitted provided the copyright notice and this notice are preserved.
18923 18925
18924;; arch-tag: 13460c90-d3bc-4be2-9e15-c7c271d0c1eb 18926;; Local Variables:
18927;; coding: iso-2022-7bit
18928;; End:
18929
18930;; arch-tag: 956fd310-042f-4fca-8dca-a01dbe06acff
diff --git a/lisp/gnus/gnus-registry.el b/lisp/gnus/gnus-registry.el
index 9a8d77d3b24..33238ef4552 100644
--- a/lisp/gnus/gnus-registry.el
+++ b/lisp/gnus/gnus-registry.el
@@ -266,25 +266,27 @@ way."
266(defun gnus-registry-trim (alist) 266(defun gnus-registry-trim (alist)
267 "Trim alist to size, using gnus-registry-max-entries." 267 "Trim alist to size, using gnus-registry-max-entries."
268 (if (null gnus-registry-max-entries) 268 (if (null gnus-registry-max-entries)
269 alist ; just return the alist 269 alist ; just return the alist
270 ;; else, when given max-entries, trim the alist 270 ;; else, when given max-entries, trim the alist
271 (let ((timehash (make-hash-table 271 (let* ((timehash (make-hash-table
272 :size 4096 272 :size 4096
273 :test 'equal))) 273 :test 'equal))
274 (trim-length (- (length alist) gnus-registry-max-entries))
275 (trim-length (if (natnump trim-length) trim-length 0)))
274 (maphash 276 (maphash
275 (lambda (key value) 277 (lambda (key value)
276 (puthash key (gnus-registry-fetch-extra key 'mtime) timehash)) 278 (puthash key (gnus-registry-fetch-extra key 'mtime) timehash))
277 gnus-registry-hashtb) 279 gnus-registry-hashtb)
278 280
279 ;; we use the return value of this setq, which is the trimmed alist 281 ;; we use the return value of this setq, which is the trimmed alist
280 (setq alist 282 (setq alist
281 (nthcdr 283 (nthcdr
282 (- (length alist) gnus-registry-max-entries) 284 trim-length
283 (sort alist 285 (sort alist
284 (lambda (a b) 286 (lambda (a b)
285 (time-less-p 287 (time-less-p
286 (cdr (gethash (car a) timehash)) 288 (cdr (gethash (car a) timehash))
287 (cdr (gethash (car b) timehash)))))))))) 289 (cdr (gethash (car b) timehash))))))))))
288 290
289(defun alist-to-hashtable (alist) 291(defun alist-to-hashtable (alist)
290 "Build a hashtable from the values in ALIST." 292 "Build a hashtable from the values in ALIST."
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index 4a7bb5ac9e7..1d1e30935cb 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -9056,8 +9056,8 @@ ACTION can be either `move' (the default), `crosspost' or `copy'."
9056 (gnus-set-mode-line 'summary))) 9056 (gnus-set-mode-line 'summary)))
9057 9057
9058(defun gnus-summary-copy-article (&optional n to-newsgroup select-method) 9058(defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9059 "Move the current article to a different newsgroup. 9059 "Copy the current article to some other group.
9060If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to. 9060If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
9061When called interactively, if TO-NEWSGROUP is nil, use the value of 9061When called interactively, if TO-NEWSGROUP is nil, use the value of
9062the variable `gnus-move-split-methods' for finding a default target 9062the variable `gnus-move-split-methods' for finding a default target
9063newsgroup. 9063newsgroup.
diff --git a/lisp/gnus/nndb.el b/lisp/gnus/nndb.el
index d29d16fa690..bd8523f11b2 100644
--- a/lisp/gnus/nndb.el
+++ b/lisp/gnus/nndb.el
@@ -1,6 +1,6 @@
1;;; nndb.el --- nndb access for Gnus 1;;; nndb.el --- nndb access for Gnus
2 2
3;; Copyright (C) 1997, 1998, 2000, 2003 Free Software Foundation, Inc. 3;; Copyright (C) 1997, 1998, 2000, 2003, 2004 Free Software Foundation, Inc.
4 4
5;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet> 5;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
6;; Kai Grossjohann <grossjohann@ls6.informatik.uni-dortmund.de> 6;; Kai Grossjohann <grossjohann@ls6.informatik.uni-dortmund.de>
@@ -60,12 +60,6 @@
60(eval-when-compile (require 'cl)) 60(eval-when-compile (require 'cl))
61 61
62(eval-and-compile 62(eval-and-compile
63 (unless (fboundp 'open-network-stream)
64 (require 'tcp)))
65
66(eval-when-compile (require 'cl))
67
68(eval-and-compile
69 (autoload 'news-setup "rnewspost") 63 (autoload 'news-setup "rnewspost")
70 (autoload 'news-reply-mode "rnewspost") 64 (autoload 'news-reply-mode "rnewspost")
71 (autoload 'cancel-timer "timer") 65 (autoload 'cancel-timer "timer")
diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el
index fc33b9a48eb..08aa48a5948 100644
--- a/lisp/gnus/nnimap.el
+++ b/lisp/gnus/nnimap.el
@@ -723,10 +723,15 @@ If EXAMINE is non-nil the group is selected read-only."
723 (int-to-string nnimap-server-port) 723 (int-to-string nnimap-server-port)
724 "imap")) 724 "imap"))
725 (alist (or (gnus-netrc-machine list server port "imap") 725 (alist (or (gnus-netrc-machine list server port "imap")
726 (gnus-netrc-machine list server port "imaps")
726 (gnus-netrc-machine list 727 (gnus-netrc-machine list
727 (or nnimap-server-address 728 (or nnimap-server-address
728 nnimap-address) 729 nnimap-address)
729 port "imap"))) 730 port "imap")
731 (gnus-netrc-machine list
732 (or nnimap-server-address
733 nnimap-address)
734 port "imaps")))
730 (user (gnus-netrc-get alist "login")) 735 (user (gnus-netrc-get alist "login"))
731 (passwd (gnus-netrc-get alist "password"))) 736 (passwd (gnus-netrc-get alist "password")))
732 (if (imap-authenticate user passwd nnimap-server-buffer) 737 (if (imap-authenticate user passwd nnimap-server-buffer)
diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el
index 96678d2bc9a..b7e6741e9d4 100644
--- a/lisp/ibuf-ext.el
+++ b/lisp/ibuf-ext.el
@@ -1015,7 +1015,10 @@ currently used by buffers."
1015 "Toggle current view to buffers with filename matching QUALIFIER." 1015 "Toggle current view to buffers with filename matching QUALIFIER."
1016 (:description "filename" 1016 (:description "filename"
1017 :reader (read-from-minibuffer "Filter by filename (regexp): ")) 1017 :reader (read-from-minibuffer "Filter by filename (regexp): "))
1018 (ibuffer-awhen (buffer-file-name buf) 1018 (ibuffer-awhen (with-current-buffer buf
1019 (or buffer-file-name
1020 (and (boundp 'dired-directory)
1021 dired-directory)))
1019 (string-match qualifier it))) 1022 (string-match qualifier it)))
1020 1023
1021;;;###autoload (autoload 'ibuffer-filter-by-size-gt "ibuf-ext.el") 1024;;;###autoload (autoload 'ibuffer-filter-by-size-gt "ibuf-ext.el")
diff --git a/lisp/ido.el b/lisp/ido.el
index ae376741f1b..b82338ef85d 100644
--- a/lisp/ido.el
+++ b/lisp/ido.el
@@ -482,14 +482,20 @@ Value can be toggled within `ido' using `ido-toggle-regexp'."
482 :group 'ido) 482 :group 'ido)
483 483
484(defcustom ido-enable-prefix nil 484(defcustom ido-enable-prefix nil
485 "*Nil means that `ido' will match if the inserted text is an 485 "*Non-nil means only match if the entered text is a prefix of file name.
486arbitrary substring (default). If non-nil `ido' will only match if the inserted 486This behavior is like the standard emacs-completion.
487text is a prefix \(this behavior is like the standard unix- or 487Nil means to match if the entered text is an arbitrary substring.
488emacs-completion works).
489Value can be toggled within `ido' using `ido-toggle-prefix'." 488Value can be toggled within `ido' using `ido-toggle-prefix'."
490 :type 'boolean 489 :type 'boolean
491 :group 'ido) 490 :group 'ido)
492 491
492(defcustom ido-enable-dot-prefix nil
493 "*Non-nil means to match leading dot as prefix.
494I.e. hidden files and buffers will match only if you type a dot
495as first char even if `ido-enable-prefix' is nil."
496 :type 'boolean
497 :group 'ido)
498
493(defcustom ido-confirm-unique-completion nil 499(defcustom ido-confirm-unique-completion nil
494 "*Non-nil means that even a unique completion must be confirmed. 500 "*Non-nil means that even a unique completion must be confirmed.
495This means that \\[ido-complete] must always be followed by \\[ido-exit-minibuffer] 501This means that \\[ido-complete] must always be followed by \\[ido-exit-minibuffer]
@@ -2928,13 +2934,22 @@ for first matching file."
2928 (concat "\\`" re "\\'"))) 2934 (concat "\\`" re "\\'")))
2929 (prefix-re (and full-re (not ido-enable-prefix) 2935 (prefix-re (and full-re (not ido-enable-prefix)
2930 (concat "\\`" rexq))) 2936 (concat "\\`" rexq)))
2937 (non-prefix-dot (or (not ido-enable-dot-prefix)
2938 (not ido-process-ignore-lists)
2939 ido-enable-prefix
2940 (= (length ido-text) 0)))
2941
2931 full-matches 2942 full-matches
2932 prefix-matches 2943 prefix-matches
2933 matches) 2944 matches)
2934 (mapcar 2945 (mapcar
2935 (lambda (item) 2946 (lambda (item)
2936 (let ((name (ido-name item))) 2947 (let ((name (ido-name item)))
2937 (if (string-match re name) 2948 (if (and (or non-prefix-dot
2949 (if (= (aref ido-text 0) ?.)
2950 (= (aref name 0) ?.)
2951 (/= (aref name 0) ?.)))
2952 (string-match re name))
2938 (cond 2953 (cond
2939 ((and full-re (string-match full-re name)) 2954 ((and full-re (string-match full-re name))
2940 (setq full-matches (cons item full-matches))) 2955 (setq full-matches (cons item full-matches)))
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 12ac2ea1165..1e8e0f6586e 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -146,8 +146,10 @@ Ordinarily the text becomes invisible again at the end of the search."
146 :type 'boolean 146 :type 'boolean
147 :group 'isearch) 147 :group 'isearch)
148 148
149(defcustom isearch-resume-enabled t 149(defcustom isearch-resume-in-command-history nil
150 "*If non-nil, `isearch-resume' commands are added to the command history." 150 "*If non-nil, `isearch-resume' commands are added to the command history.
151This allows you to resume earlier isearch sessions through the
152command history."
151 :type 'boolean 153 :type 'boolean
152 :group 'isearch) 154 :group 'isearch)
153 155
@@ -647,7 +649,7 @@ is treated as a regexp. See \\[isearch-forward] for more info."
647 (setq disable-point-adjustment t)) 649 (setq disable-point-adjustment t))
648 650
649(defun isearch-done (&optional nopush edit) 651(defun isearch-done (&optional nopush edit)
650 (if isearch-resume-enabled 652 (if isearch-resume-in-command-history
651 (let ((command `(isearch-resume ,isearch-string ,isearch-regexp 653 (let ((command `(isearch-resume ,isearch-string ,isearch-regexp
652 ,isearch-word ,isearch-forward 654 ,isearch-word ,isearch-forward
653 ,isearch-message 655 ,isearch-message
diff --git a/lisp/kmacro.el b/lisp/kmacro.el
index a129ab53cef..5aefe46625d 100644
--- a/lisp/kmacro.el
+++ b/lisp/kmacro.el
@@ -204,7 +204,7 @@ macro to be executed before appending to it."
204 204
205 ;; naming and binding 205 ;; naming and binding
206 (define-key map "b" 'kmacro-bind-to-key) 206 (define-key map "b" 'kmacro-bind-to-key)
207 (define-key map "n" 'name-last-kbd-macro) 207 (define-key map "n" 'kmacro-name-last-macro)
208 map) 208 map)
209 "Keymap for keyboard macro commands.") 209 "Keymap for keyboard macro commands.")
210(defalias 'kmacro-keymap kmacro-keymap) 210(defalias 'kmacro-keymap kmacro-keymap)
@@ -539,8 +539,8 @@ Displays the selected macro in the echo area."
539The commands are recorded even as they are executed. 539The commands are recorded even as they are executed.
540Use \\[kmacro-end-macro] to finish recording and make the macro available. 540Use \\[kmacro-end-macro] to finish recording and make the macro available.
541Use \\[kmacro-end-and-call-macro] to execute the macro. 541Use \\[kmacro-end-and-call-macro] to execute the macro.
542Use \\[name-last-kbd-macro] to give it a permanent name. 542
543Non-nil arg (prefix arg) means append to last macro defined; 543Non-nil arg (prefix arg) means append to last macro defined.
544 544
545With \\[universal-argument] prefix, append to last keyboard macro 545With \\[universal-argument] prefix, append to last keyboard macro
546defined. Depending on `kmacro-execute-before-append', this may begin 546defined. Depending on `kmacro-execute-before-append', this may begin
@@ -551,7 +551,10 @@ defining the macro.
551 551
552Use \\[kmacro-insert-counter] to insert (and increment) the macro counter. 552Use \\[kmacro-insert-counter] to insert (and increment) the macro counter.
553The counter value can be set or modified via \\[kmacro-set-counter] and \\[kmacro-add-counter]. 553The counter value can be set or modified via \\[kmacro-set-counter] and \\[kmacro-add-counter].
554The format of the counter can be modified via \\[kmacro-set-format]." 554The format of the counter can be modified via \\[kmacro-set-format].
555
556Use \\[kmacro-name-last-macro] to give it a permanent name.
557Use \\[kmacro-bind-to-key] to bind it to a key sequence."
555 (interactive "P") 558 (interactive "P")
556 (if (or defining-kbd-macro executing-kbd-macro) 559 (if (or defining-kbd-macro executing-kbd-macro)
557 (message "Already defining keyboard macro.") 560 (message "Already defining keyboard macro.")
@@ -585,7 +588,7 @@ The format of the counter can be modified via \\[kmacro-set-format]."
585 "Finish defining a keyboard macro. 588 "Finish defining a keyboard macro.
586The definition was started by \\[kmacro-start-macro]. 589The definition was started by \\[kmacro-start-macro].
587The macro is now available for use via \\[kmacro-call-macro], 590The macro is now available for use via \\[kmacro-call-macro],
588or it can be given a name with \\[name-last-kbd-macro] and then invoked 591or it can be given a name with \\[kmacro-name-last-macro] and then invoked
589under that name. 592under that name.
590 593
591With numeric arg, repeat macro now that many times, 594With numeric arg, repeat macro now that many times,
@@ -609,7 +612,7 @@ command. See `kmacro-call-repeat-key' and `kmacro-call-repeat-with-arg'
609for details on how to adjust or disable this behaviour. 612for details on how to adjust or disable this behaviour.
610 613
611To make a macro permanent so you can call it even after defining 614To make a macro permanent so you can call it even after defining
612others, use \\[name-last-kbd-macro]." 615others, use \\[kmacro-name-last-macro]."
613 (interactive "p") 616 (interactive "p")
614 (let ((repeat-key (and (null no-repeat) 617 (let ((repeat-key (and (null no-repeat)
615 (> (length (this-single-command-keys)) 1) 618 (> (length (this-single-command-keys)) 1)
@@ -707,7 +710,7 @@ With numeric prefix ARG, repeat macro that many times.
707Zero argument means repeat until there is an error. 710Zero argument means repeat until there is an error.
708 711
709To give a macro a permanent name, so you can call it 712To give a macro a permanent name, so you can call it
710even after defining other macros, use \\[name-last-kbd-macro]." 713even after defining other macros, use \\[kmacro-name-last-macro]."
711 (interactive "P") 714 (interactive "P")
712 (if defining-kbd-macro 715 (if defining-kbd-macro
713 (kmacro-end-macro nil)) 716 (kmacro-end-macro nil))
@@ -771,10 +774,38 @@ may be shaded by a local key binding."
771 (yes-or-no-p (format "%s runs command %S. Bind anyway? " 774 (yes-or-no-p (format "%s runs command %S. Bind anyway? "
772 (format-kbd-macro key-seq) 775 (format-kbd-macro key-seq)
773 cmd)))) 776 cmd))))
774 (define-key global-map key-seq last-kbd-macro) 777 (define-key global-map key-seq
778 `(lambda (&optional arg)
779 "Keyboard macro."
780 (interactive "p")
781 (kmacro-exec-ring-item ',(kmacro-ring-head) arg)))
775 (message "Keyboard macro bound to %s" (format-kbd-macro key-seq)))))) 782 (message "Keyboard macro bound to %s" (format-kbd-macro key-seq))))))
776 783
777 784
785(defun kmacro-name-last-macro (symbol)
786 "Assign a name to the last keyboard macro defined.
787Argument SYMBOL is the name to define.
788The symbol's function definition becomes the keyboard macro string.
789Such a \"function\" cannot be called from Lisp, but it is a valid editor command."
790 (interactive "SName for last kbd macro: ")
791 (or last-kbd-macro
792 (error "No keyboard macro defined"))
793 (and (fboundp symbol)
794 (not (get symbol 'kmacro))
795 (not (stringp (symbol-function symbol)))
796 (not (vectorp (symbol-function symbol)))
797 (error "Function %s is already defined and not a keyboard macro"
798 symbol))
799 (if (string-equal symbol "")
800 (error "No command name given"))
801 (fset symbol
802 `(lambda (&optional arg)
803 "Keyboard macro."
804 (interactive "p")
805 (kmacro-exec-ring-item ',(kmacro-ring-head) arg)))
806 (put symbol 'kmacro t))
807
808
778(defun kmacro-view-macro (&optional arg) 809(defun kmacro-view-macro (&optional arg)
779 "Display the last keyboard macro. 810 "Display the last keyboard macro.
780If repeated, it shows previous elements in the macro ring." 811If repeated, it shows previous elements in the macro ring."
@@ -897,7 +928,8 @@ following additional answers: `insert', `insert-1', `replace', `replace-1',
897 (curmsg (current-message))) 928 (curmsg (current-message)))
898 929
899 ;; TODO: Scroll macro if max-mini-window-height is too small. 930 ;; TODO: Scroll macro if max-mini-window-height is too small.
900 (message (concat 931 (message "%s"
932 (concat
901 (format "Macro: %s%s%s%s%s\n" 933 (format "Macro: %s%s%s%s%s\n"
902 (format-kbd-macro kmacro-step-edit-new-macro 1) 934 (format-kbd-macro kmacro-step-edit-new-macro 1)
903 (if (and kmacro-step-edit-new-macro (> (length kmacro-step-edit-new-macro) 0)) " " "") 935 (if (and kmacro-step-edit-new-macro (> (length kmacro-step-edit-new-macro) 0)) " " "")
diff --git a/lisp/novice.el b/lisp/novice.el
index ca9a06769d5..b2a0bec0204 100644
--- a/lisp/novice.el
+++ b/lisp/novice.el
@@ -44,7 +44,7 @@ If nil, the feature is disabled, i.e., all commands work normally.")
44(defvaralias 'disabled-command-hook 'disabled-command-function) 44(defvaralias 'disabled-command-hook 'disabled-command-function)
45(make-obsolete-variable 45(make-obsolete-variable
46 'disabled-command-hook 46 'disabled-command-hook
47 "use the variable `disabled-command-function' instead." "21.4") 47 'disabled-command-function "21.4")
48 48
49;;;###autoload 49;;;###autoload
50(defun disabled-command-function (&rest ignore) 50(defun disabled-command-function (&rest ignore)
@@ -93,7 +93,7 @@ SPC to try the command just this once, but leave it disabled.
93 (message "Type y, n, ! or SPC (the space bar): ") 93 (message "Type y, n, ! or SPC (the space bar): ")
94 (let ((cursor-in-echo-area t)) 94 (let ((cursor-in-echo-area t))
95 (while (not (memq (setq char (downcase (read-char))) 95 (while (not (memq (setq char (downcase (read-char)))
96 '(?! ? ?y ?n))) 96 '(?! ?y ?n ?\ )))
97 (ding) 97 (ding)
98 (message "Please type y, n, ! or SPC (the space bar): ")))) 98 (message "Please type y, n, ! or SPC (the space bar): "))))
99 (if (= char ?!) 99 (if (= char ?!)
@@ -185,5 +185,5 @@ to future sessions."
185 185
186(provide 'novice) 186(provide 'novice)
187 187
188;;; arch-tag: f83c0f96-497e-4db6-a430-8703716c6dd9 188;; arch-tag: f83c0f96-497e-4db6-a430-8703716c6dd9
189;;; novice.el ends here 189;;; novice.el ends here
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 8ae2a7abe76..2f910608d5c 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -849,6 +849,7 @@ Otherwise, construct a buffer name from MODE-NAME."
849 849
850(defun compilation-start (command &optional mode name-function highlight-regexp) 850(defun compilation-start (command &optional mode name-function highlight-regexp)
851 "Run compilation command COMMAND (low level interface). 851 "Run compilation command COMMAND (low level interface).
852If COMMAND starts with a cd command, that becomes the `default-directory'.
852The rest of the arguments are optional; for them, nil means use the default. 853The rest of the arguments are optional; for them, nil means use the default.
853 854
854MODE is the major mode to set in the compilation buffer. Mode 855MODE is the major mode to set in the compilation buffer. Mode
@@ -861,26 +862,29 @@ global value of `compilation-highlight-regexp'.
861 862
862Returns the compilation buffer created." 863Returns the compilation buffer created."
863 (or mode (setq mode 'compilation-mode)) 864 (or mode (setq mode 'compilation-mode))
864 (let ((name-of-mode 865 (let* ((name-of-mode
865 (if (eq mode t) 866 (if (eq mode t)
866 (prog1 "compilation" (require 'comint)) 867 (prog1 "compilation" (require 'comint))
867 (replace-regexp-in-string "-mode$" "" (symbol-name mode)))) 868 (replace-regexp-in-string "-mode$" "" (symbol-name mode))))
868 (process-environment 869 (process-environment
869 (append 870 (append
870 compilation-environment 871 compilation-environment
871 (if (if (boundp 'system-uses-terminfo) ; `if' for compiler warning 872 (if (if (boundp 'system-uses-terminfo) ; `if' for compiler warning
872 system-uses-terminfo) 873 system-uses-terminfo)
873 (list "TERM=dumb" "TERMCAP=" 874 (list "TERM=dumb" "TERMCAP="
874 (format "COLUMNS=%d" (window-width))) 875 (format "COLUMNS=%d" (window-width)))
875 (list "TERM=emacs" 876 (list "TERM=emacs"
876 (format "TERMCAP=emacs:co#%d:tc=unknown:" 877 (format "TERMCAP=emacs:co#%d:tc=unknown:"
877 (window-width)))) 878 (window-width))))
878 ;; Set the EMACS variable, but 879 ;; Set the EMACS variable, but
879 ;; don't override users' setting of $EMACS. 880 ;; don't override users' setting of $EMACS.
880 (unless (getenv "EMACS") '("EMACS=t")) 881 (unless (getenv "EMACS") '("EMACS=t"))
881 (copy-sequence process-environment))) 882 (copy-sequence process-environment)))
882 (thisdir default-directory) 883 cd-path ; in case process-environment contains CDPATH
883 outwin outbuf) 884 (thisdir (if (string-match "^\\s *cd\\s +\\(.+?\\)\\s *[;&\n]" command)
885 (substitute-in-file-name (match-string 1 command))
886 default-directory))
887 outwin outbuf)
884 (with-current-buffer 888 (with-current-buffer
885 (setq outbuf 889 (setq outbuf
886 (get-buffer-create 890 (get-buffer-create
@@ -901,15 +905,16 @@ Returns the compilation buffer created."
901 (buffer-name))))) 905 (buffer-name)))))
902 ;; Clear out the compilation buffer and make it writable. 906 ;; Clear out the compilation buffer and make it writable.
903 ;; Change its default-directory to the directory where the compilation 907 ;; Change its default-directory to the directory where the compilation
904 ;; will happen, and insert a `cd' command to indicate this. 908 ;; will happen, and insert a `default-directory' to indicate this.
905 (setq buffer-read-only nil) 909 (setq buffer-read-only nil)
906 (buffer-disable-undo (current-buffer)) 910 (buffer-disable-undo (current-buffer))
907 (erase-buffer) 911 (erase-buffer)
908 (buffer-enable-undo (current-buffer)) 912 (buffer-enable-undo (current-buffer))
909 (setq default-directory thisdir) 913 (cd thisdir)
910 ;; output a mode setter, for saving and later reloading this buffer 914 ;; output a mode setter, for saving and later reloading this buffer
911 (insert "cd " thisdir " # -*-" name-of-mode 915 (insert "-*- mode: " name-of-mode
912 "-*-\nEntering directory `" thisdir "'\n" command "\n") 916 "; default-directory: " (prin1-to-string default-directory)
917 " -*-\n" command "\n")
913 (set-buffer-modified-p nil)) 918 (set-buffer-modified-p nil))
914 ;; If we're already in the compilation buffer, go to the end 919 ;; If we're already in the compilation buffer, go to the end
915 ;; of the buffer, so point will track the compilation output. 920 ;; of the buffer, so point will track the compilation output.
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index 083540c7820..4d9e05109a8 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -500,17 +500,6 @@ temporarily highlight in visited source lines."
500 command-args) 500 command-args)
501 'grep-mode nil highlight-regexp))) 501 'grep-mode nil highlight-regexp)))
502 502
503;;; This doesn't work:
504;;; ###autoload (autoload 'grep-mode "grep" nil t)
505;;; The ostensibly correct result is nonetheless opaque to the accounting
506;;; done in `generate-file-autoloads'; in loaddefs.el, the generated elisp is
507;;; correct but the generated header comment for grep.el lacks `grep-mode'.
508;;; This approach also doesn't help other users of `define-compilation-mode'
509;;; who wish to autoload.
510;;;
511;;; Better to extend autoload.el to grok `define-compilation-mode'.
512
513;;;###autoload
514(define-compilation-mode grep-mode "Grep" 503(define-compilation-mode grep-mode "Grep"
515 "Sets `grep-last-buffer' and `compilation-window-height'." 504 "Sets `grep-last-buffer' and `compilation-window-height'."
516 (setq grep-last-buffer (current-buffer)) 505 (setq grep-last-buffer (current-buffer))
@@ -626,5 +615,5 @@ those sub directories of DIR."
626 615
627(provide 'grep) 616(provide 'grep)
628 617
629;;; arch-tag: 5a5b9169-a79d-4f38-9c38-f69615f39c4d 618;; arch-tag: 5a5b9169-a79d-4f38-9c38-f69615f39c4d
630;;; grep.el ends here 619;;; grep.el ends here
diff --git a/lisp/simple.el b/lisp/simple.el
index 9bc81759715..899534a899a 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -4297,11 +4297,12 @@ to decide what to delete."
4297 (not (equal buffer 4297 (not (equal buffer
4298 (window-buffer (active-minibuffer-window)))))) 4298 (window-buffer (active-minibuffer-window))))))
4299 (error "Minibuffer is not active for completion") 4299 (error "Minibuffer is not active for completion")
4300 ;; Set buffer so buffer-local choose-completion-string-functions works.
4301 (set-buffer buffer)
4300 (unless (run-hook-with-args-until-success 4302 (unless (run-hook-with-args-until-success
4301 'choose-completion-string-functions 4303 'choose-completion-string-functions
4302 choice buffer mini-p base-size) 4304 choice buffer mini-p base-size)
4303 ;; Insert the completion into the buffer where it was requested. 4305 ;; Insert the completion into the buffer where it was requested.
4304 (set-buffer buffer)
4305 (if base-size 4306 (if base-size
4306 (delete-region (+ base-size (if mini-p 4307 (delete-region (+ base-size (if mini-p
4307 (minibuffer-prompt-end) 4308 (minibuffer-prompt-end)
diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el
index 15348205c51..ddc1d4ecb62 100644
--- a/lisp/textmodes/bibtex.el
+++ b/lisp/textmodes/bibtex.el
@@ -1,6 +1,6 @@
1;;; bibtex.el --- BibTeX mode for GNU Emacs 1;;; bibtex.el --- BibTeX mode for GNU Emacs
2 2
3;; Copyright (C) 1992,94,95,96,97,98,1999,2003,2004 3;; Copyright (C) 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2003, 2004
4;; Free Software Foundation, Inc. 4;; Free Software Foundation, Inc.
5 5
6;; Author: Stefan Schoef <schoef@offis.uni-oldenburg.de> 6;; Author: Stefan Schoef <schoef@offis.uni-oldenburg.de>
@@ -61,13 +61,13 @@
61 :type 'hook) 61 :type 'hook)
62 62
63(defcustom bibtex-field-delimiters 'braces 63(defcustom bibtex-field-delimiters 'braces
64 "*Type of field delimiters. Allowed values are `braces' or `double-quotes'." 64 "*Type of field delimiters. Allowed values are `braces' or `double-quotes'."
65 :group 'bibtex 65 :group 'bibtex
66 :type '(choice (const braces) 66 :type '(choice (const braces)
67 (const double-quotes))) 67 (const double-quotes)))
68 68
69(defcustom bibtex-entry-delimiters 'braces 69(defcustom bibtex-entry-delimiters 'braces
70 "*Type of entry delimiters. Allowed values are `braces' or `parentheses'." 70 "*Type of entry delimiters. Allowed values are `braces' or `parentheses'."
71 :group 'bibtex 71 :group 'bibtex
72 :type '(choice (const braces) 72 :type '(choice (const braces)
73 (const parentheses))) 73 (const parentheses)))
@@ -154,10 +154,10 @@ narrowed to just the entry."
154Allowed non-nil values are: 154Allowed non-nil values are:
155plain All entries are sorted alphabetically. 155plain All entries are sorted alphabetically.
156crossref All entries are sorted alphabetically unless an entry has a 156crossref All entries are sorted alphabetically unless an entry has a
157 crossref field. These crossrefed entries are placed in 157 crossref field. These crossrefed entries are placed in
158 alphabetical order immediately preceding the main entry. 158 alphabetical order immediately preceding the main entry.
159entry-class The entries are divided into classes according to their 159entry-class The entries are divided into classes according to their
160 entry name, see `bibtex-sort-entry-class'. Within each class 160 entry name, see `bibtex-sort-entry-class'. Within each class
161 the entries are sorted alphabetically. 161 the entries are sorted alphabetically.
162See also `bibtex-sort-ignore-string-entries'." 162See also `bibtex-sort-ignore-string-entries'."
163 :group 'bibtex 163 :group 'bibtex
@@ -172,8 +172,8 @@ See also `bibtex-sort-ignore-string-entries'."
172 ("Book" "Proceedings")) 172 ("Book" "Proceedings"))
173 "*List of classes of BibTeX entry names, used for sorting entries. 173 "*List of classes of BibTeX entry names, used for sorting entries.
174If value of `bibtex-maintain-sorted-entries' is `entry-class' 174If value of `bibtex-maintain-sorted-entries' is `entry-class'
175entries are ordered according to the classes they belong to. Each 175entries are ordered according to the classes they belong to. Each
176class contains a list of entry names. An entry `catch-all' applies 176class contains a list of entry names. An entry `catch-all' applies
177to all entries not explicitely mentioned.") 177to all entries not explicitely mentioned.")
178 178
179(defcustom bibtex-sort-ignore-string-entries t 179(defcustom bibtex-sort-ignore-string-entries t
@@ -640,7 +640,7 @@ See `bibtex-generate-autokey' for details."
640 640
641(defcustom bibtex-autokey-titleword-ignore 641(defcustom bibtex-autokey-titleword-ignore
642 '("A" "An" "On" "The" "Eine?" "Der" "Die" "Das" 642 '("A" "An" "On" "The" "Eine?" "Der" "Die" "Das"
643 "[^A-Z].*" ".*[^a-zA-Z0-9].*") 643 "[^A-Z].*" ".*[^A-Z0-9].*")
644 "*Determines words from the title that are not to be used in the key. 644 "*Determines words from the title that are not to be used in the key.
645Each item of the list is a regexp. If a word of the title matchs a 645Each item of the list is a regexp. If a word of the title matchs a
646regexp from that list, it is not included in the title part of the key. 646regexp from that list, it is not included in the title part of the key.
@@ -762,11 +762,47 @@ If non-nil, the column for the equal sign is the value of
762 "Automatically fill fields if possible for those BibTeX entry types." 762 "Automatically fill fields if possible for those BibTeX entry types."
763 :type '(repeat string)) 763 :type '(repeat string))
764 764
765(defcustom bibtex-complete-key-cleanup nil 765(defcustom bibtex-generate-url-list
766 "*Function called by `bibtex-complete' after insertion of a key fragment." 766 '((("url" . ".*:.*"))
767 :group 'bibtex-autokey 767 ;; Example of a complex setup.
768 :type '(choice (const :tag "None" nil) 768 (("journal" . "\\<\\(PR[ABCDEL]?\\|RMP\\)\\>")
769 (function :tag "Cleanup function"))) 769 "http://publish.aps.org/abstract/"
770 ("journal" ".*" downcase)
771 "/v"
772 ("volume" ".*" 0)
773 "/p"
774 ("pages" "\\`\\([0-9]+\\)" 1)))
775 "List of schemes for generating the URL of a BibTeX entry.
776These schemes are used by `bibtex-url'.
777
778Each scheme is of the form ((FIELD . REGEXP) STEP...).
779
780FIELD is a field name as returned by `bibtex-parse-entry'.
781REGEXP is matched against the text of FIELD. If the match succeed, then
782this scheme will be used. If no STEPS are specified the matched text is used
783as the URL, otherwise the URL is built by concatenating the STEPS.
784
785A STEP can be a string or a list (FIELD REGEXP REPLACE) in which case
786the text of FIELD is matched against REGEXP, and is replaced with REPLACE.
787REPLACE can be a string, or a number (which selects the corresponding submatch)
788or a function called with the field's text as argument and with the
789`match-data' properly set.
790
791Case is always ignored. Always remove the field delimiters."
792 :group 'bibtex
793 :type '(repeat
794 (list :tag "Scheme"
795 (cons :tag "Matcher" :extra-offset 4
796 (string :tag "BibTeX field")
797 (regexp :tag "Regexp"))
798 (repeat :tag "Steps to generate URL" :inline t
799 (choice
800 (string :tag "Literal text")
801 (list (string :tag "BibTeX field")
802 (regexp :tag "Regexp")
803 (choice (string :tag "Replacement")
804 (integer :tag "Sub-match")
805 (function :tag "Filter"))))))))
770 806
771;; bibtex-font-lock-keywords is a user option as well, but since the 807;; bibtex-font-lock-keywords is a user option as well, but since the
772;; patterns used to define this variable are defined in a later 808;; patterns used to define this variable are defined in a later
@@ -801,6 +837,7 @@ If non-nil, the column for the equal sign is the value of
801 (define-key km "\C-c}" 'bibtex-remove-delimiters) 837 (define-key km "\C-c}" 'bibtex-remove-delimiters)
802 (define-key km "\C-c\C-c" 'bibtex-clean-entry) 838 (define-key km "\C-c\C-c" 'bibtex-clean-entry)
803 (define-key km "\C-c\C-q" 'bibtex-fill-entry) 839 (define-key km "\C-c\C-q" 'bibtex-fill-entry)
840 (define-key km "\C-c\C-s" 'bibtex-find-entry)
804 (define-key km "\C-c?" 'bibtex-print-help-message) 841 (define-key km "\C-c?" 'bibtex-print-help-message)
805 (define-key km "\C-c\C-p" 'bibtex-pop-previous) 842 (define-key km "\C-c\C-p" 'bibtex-pop-previous)
806 (define-key km "\C-c\C-n" 'bibtex-pop-next) 843 (define-key km "\C-c\C-n" 'bibtex-pop-next)
@@ -821,6 +858,7 @@ If non-nil, the column for the equal sign is the value of
821 (define-key km "\C-c\C-b" 'bibtex-entry) 858 (define-key km "\C-c\C-b" 'bibtex-entry)
822 (define-key km "\C-c\C-rn" 'bibtex-narrow-to-entry) 859 (define-key km "\C-c\C-rn" 'bibtex-narrow-to-entry)
823 (define-key km "\C-c\C-rw" 'widen) 860 (define-key km "\C-c\C-rw" 'widen)
861 (define-key km "\C-c\C-l" 'bibtex-url)
824 (define-key km "\C-c\C-o" 'bibtex-remove-OPT-or-ALT) 862 (define-key km "\C-c\C-o" 'bibtex-remove-OPT-or-ALT)
825 (define-key km "\C-c\C-e\C-i" 'bibtex-InProceedings) 863 (define-key km "\C-c\C-e\C-i" 'bibtex-InProceedings)
826 (define-key km "\C-c\C-ei" 'bibtex-InCollection) 864 (define-key km "\C-c\C-ei" 'bibtex-InCollection)
@@ -854,21 +892,7 @@ If non-nil, the column for the equal sign is the value of
854 ("Moving in BibTeX Buffer" 892 ("Moving in BibTeX Buffer"
855 ["Find Entry" bibtex-find-entry t] 893 ["Find Entry" bibtex-find-entry t]
856 ["Find Crossref Entry" bibtex-find-crossref t]) 894 ["Find Crossref Entry" bibtex-find-crossref t])
857 ("Operating on Current Entry"
858 ["Fill Entry" bibtex-fill-entry t]
859 ["Clean Entry" bibtex-clean-entry t]
860 "--" 895 "--"
861 ["Kill Entry" bibtex-kill-entry t]
862 ["Copy Entry to Kill Ring" bibtex-copy-entry-as-kill t]
863 ["Paste Most Recently Killed Entry" bibtex-yank t]
864 ["Paste Previously Killed Entry" bibtex-yank-pop t]
865 "--"
866 ["Ispell Entry" bibtex-ispell-entry t]
867 ["Ispell Entry Abstract" bibtex-ispell-abstract t]
868 ["Narrow to Entry" bibtex-narrow-to-entry t]
869 "--"
870 ["View Cite Locations (RefTeX)" reftex-view-crossref-from-bibtex
871 (fboundp 'reftex-view-crossref-from-bibtex)])
872 ("Operating on Current Field" 896 ("Operating on Current Field"
873 ["Fill Field" fill-paragraph t] 897 ["Fill Field" fill-paragraph t]
874 ["Remove Delimiters" bibtex-remove-delimiters t] 898 ["Remove Delimiters" bibtex-remove-delimiters t]
@@ -888,12 +912,28 @@ If non-nil, the column for the equal sign is the value of
888 ["String or Key Complete" bibtex-complete t] 912 ["String or Key Complete" bibtex-complete t]
889 "--" 913 "--"
890 ["Help about Current Field" bibtex-print-help-message t]) 914 ["Help about Current Field" bibtex-print-help-message t])
915 ("Operating on Current Entry"
916 ["Fill Entry" bibtex-fill-entry t]
917 ["Clean Entry" bibtex-clean-entry t]
918 ["Update Entry" bibtex-entry-update t]
919 "--"
920 ["Kill Entry" bibtex-kill-entry t]
921 ["Copy Entry to Kill Ring" bibtex-copy-entry-as-kill t]
922 ["Paste Most Recently Killed Entry" bibtex-yank t]
923 ["Paste Previously Killed Entry" bibtex-yank-pop t]
924 "--"
925 ["Ispell Entry" bibtex-ispell-entry t]
926 ["Ispell Entry Abstract" bibtex-ispell-abstract t]
927 ["Narrow to Entry" bibtex-narrow-to-entry t]
928 "--"
929 ["View Cite Locations (RefTeX)" reftex-view-crossref-from-bibtex
930 (fboundp 'reftex-view-crossref-from-bibtex)])
891 ("Operating on Buffer or Region" 931 ("Operating on Buffer or Region"
892 ["Validate Entries" bibtex-validate t] 932 ["Validate Entries" bibtex-validate t]
893 ["Sort Entries" bibtex-sort-buffer t] 933 ["Sort Entries" bibtex-sort-buffer t]
894 ["Reformat Entries" bibtex-reformat t] 934 ["Reformat Entries" bibtex-reformat t]
895 ["Count Entries" bibtex-count-entries t]) 935 ["Count Entries" bibtex-count-entries t]
896 ("Miscellaneous" 936 "--"
897 ["Convert Alien Buffer" bibtex-convert-alien t]))) 937 ["Convert Alien Buffer" bibtex-convert-alien t])))
898 938
899(easy-menu-define 939(easy-menu-define
@@ -915,6 +955,13 @@ If non-nil, the column for the equal sign is the value of
915 ["String" bibtex-String t] 955 ["String" bibtex-String t]
916 ["Preamble" bibtex-Preamble t])) 956 ["Preamble" bibtex-Preamble t]))
917 957
958(defvar bibtex-url-map
959 (let ((km (make-sparse-keymap)))
960 (define-key km [(mouse-2)] 'bibtex-url)
961 km)
962 "Local keymap for clickable URLs.")
963(fset 'bibtex-url-map bibtex-url-map)
964
918 965
919;; Internal Variables 966;; Internal Variables
920 967
@@ -954,8 +1001,7 @@ Initialized from `bibtex-predefined-strings' and `bibtex-string-files'.")
954(make-variable-buffer-local 'bibtex-reference-keys) 1001(make-variable-buffer-local 'bibtex-reference-keys)
955 1002
956(defvar bibtex-buffer-last-parsed-tick nil 1003(defvar bibtex-buffer-last-parsed-tick nil
957 "Last value returned by `buffer-modified-tick' when buffer 1004 "Value of `buffer-modified-tick' last time buffer was parsed for keys.")
958was parsed for keys the last time.")
959 1005
960(defvar bibtex-parse-idle-timer nil 1006(defvar bibtex-parse-idle-timer nil
961 "Stores if timer is already installed.") 1007 "Stores if timer is already installed.")
@@ -1040,41 +1086,35 @@ was parsed for keys the last time.")
1040(defconst bibtex-empty-field-re "\"\"\\|{}" 1086(defconst bibtex-empty-field-re "\"\"\\|{}"
1041 "Regexp matching an empty field.") 1087 "Regexp matching an empty field.")
1042 1088
1043(defconst bibtex-quoted-string-re
1044 (concat "\""
1045 "\\("
1046 "[^\"\\]" ; anything but quote or backslash
1047 "\\|"
1048 "\\("
1049 "\\\\\\(.\\|\n\\)" ; any backslash quoted character
1050 "\\)"
1051 "\\)*"
1052 "\"")
1053 "Regexp matching a field string enclosed by quotes.")
1054
1055(defconst bibtex-font-lock-syntactic-keywords 1089(defconst bibtex-font-lock-syntactic-keywords
1056 `((,(concat "^[ \t]*\\(" (substring bibtex-comment-start 0 1) "\\)" 1090 `((,(concat "^[ \t]*\\(" (substring bibtex-comment-start 0 1) "\\)"
1057 (substring bibtex-comment-start 1) "\\>") 1091 (substring bibtex-comment-start 1) "\\>")
1058 1 '(11)))) 1092 1 '(11))))
1059 1093
1060(defvar bibtex-font-lock-keywords 1094(defvar bibtex-font-lock-keywords
1061 (list 1095 ;; entry type and reference key
1062 ;; entry type and reference key 1096 `((,bibtex-entry-maybe-empty-head
1063 (list bibtex-entry-maybe-empty-head 1097 (,bibtex-type-in-head font-lock-function-name-face)
1064 (list bibtex-type-in-head 'font-lock-function-name-face) 1098 (,bibtex-key-in-head font-lock-constant-face nil t))
1065 (list bibtex-key-in-head 'font-lock-constant-face nil t)) 1099 ;; optional field names (treated as comments)
1066 ;; optional field names (treated as comments) 1100 (,(concat "^[ \t]*\\(OPT" bibtex-field-name "\\)[ \t]*=")
1067 (list 1101 1 font-lock-comment-face)
1068 (concat "^[ \t]*\\(OPT" bibtex-field-name "\\)[ \t]*=") 1102 ;; field names
1069 1 'font-lock-comment-face) 1103 (,(concat "^[ \t]*\\(" bibtex-field-name "\\)[ \t]*=")
1070 ;; field names 1104 1 font-lock-variable-name-face)
1071 (list (concat "^[ \t]*\\(" bibtex-field-name "\\)[ \t]*=") 1105 ;; url
1072 1 'font-lock-variable-name-face)) 1106 (bibtex-font-lock-url 0 '(face nil mouse-face highlight
1107 keymap bibtex-url-map)))
1073 "*Default expressions to highlight in BibTeX mode.") 1108 "*Default expressions to highlight in BibTeX mode.")
1074 1109
1110(defvar bibtex-font-lock-url-regexp
1111 (concat "\\<" (regexp-opt (mapcar 'caar bibtex-generate-url-list) t)
1112 "\\>[ \t]*=[ \t]*")
1113 "Regexp for `bibtex-font-lock-url'.")
1114
1075(defvar bibtex-field-name-for-parsing nil 1115(defvar bibtex-field-name-for-parsing nil
1076 "Temporary variable storing the name string to be parsed by the callback 1116 "Regexp of field name to be parsed by function `bibtex-parse-field-name'.
1077function `bibtex-parse-field-name'.") 1117Passed by dynamic scoping.")
1078 1118
1079(defvar bibtex-sort-entry-class-alist 1119(defvar bibtex-sort-entry-class-alist
1080 (let ((i -1) alist) 1120 (let ((i -1) alist)
@@ -1083,41 +1123,38 @@ function `bibtex-parse-field-name'.")
1083 (dolist (entry class) 1123 (dolist (entry class)
1084 ;; all entry names should be downcase (for ease of comparison) 1124 ;; all entry names should be downcase (for ease of comparison)
1085 (push (cons (if (stringp entry) (downcase entry) entry) i) alist)))) 1125 (push (cons (if (stringp entry) (downcase entry) entry) i) alist))))
1086 "Alist for the classes of the entry types if the value of 1126 "Alist mapping entry types to their sorting index.
1087`bibtex-maintain-sorted-entries' is `entry-class'.") 1127Auto-generated from `bibtex-sort-entry-class'.
1128Used when `bibtex-maintain-sorted-entries' is `entry-class'.")
1088 1129
1089 1130
1090;; Special support taking care of variants 1131;; Special support taking care of variants
1091(defvar zmacs-regions) 1132(defvar zmacs-regions)
1092(if (boundp 'mark-active) 1133(defalias 'bibtex-mark-active
1093 (defun bibtex-mark-active () 1134 (if (boundp 'mark-active)
1094 ;; In Emacs mark-active indicates if mark is active. 1135 ;; In Emacs mark-active indicates if mark is active.
1095 mark-active) 1136 (lambda () mark-active)
1096 (defun bibtex-mark-active ()
1097 ;; In XEmacs (mark) returns nil when not active. 1137 ;; In XEmacs (mark) returns nil when not active.
1098 (if zmacs-regions (mark) (mark t)))) 1138 (lambda () (if zmacs-regions (mark) (mark t)))))
1099 1139
1100(if (fboundp 'run-with-idle-timer) 1140(defalias 'bibtex-run-with-idle-timer
1101 ;; timer.el is distributed with Emacs 1141 (if (fboundp 'run-with-idle-timer)
1102 (fset 'bibtex-run-with-idle-timer 'run-with-idle-timer) 1142 ;; timer.el is distributed with Emacs
1103 ;; timer.el is not distributed with XEmacs 1143 'run-with-idle-timer
1104 ;; Notice that this does not (yet) pass the arguments, but they 1144 ;; timer.el is not distributed with XEmacs
1105 ;; are not used (yet) in bibtex.el. Fix if needed. 1145 ;; Notice that this does not (yet) pass the arguments, but they
1106 (defun bibtex-run-with-idle-timer (secs repeat function &rest args) 1146 ;; are not used (yet) in bibtex.el. Fix if needed.
1107 (start-itimer "bibtex" function secs (if repeat secs nil) t))) 1147 (lambda (secs repeat function &rest args)
1148 (start-itimer "bibtex" function secs (if repeat secs nil) t))))
1108 1149
1109 1150
1110;; Support for hideshow minor mode 1151;; Support for hideshow minor mode
1111(defun bibtex-hs-forward-sexp (arg) 1152(defun bibtex-hs-forward-sexp (arg)
1112 "Replacement for `forward-sexp' to be used by `hs-minor-mode'." 1153 "Replacement for `forward-sexp' to be used by `hs-minor-mode'.
1113 (if (< arg 0) 1154ARG is ignored."
1114 (backward-sexp 1) 1155 (if (looking-at "@\\S(*\\s(")
1115 (if (looking-at "@\\S(*\\s(") 1156 (goto-char (1- (match-end 0))))
1116 (progn 1157 (forward-sexp 1))
1117 (goto-char (match-end 0))
1118 (forward-char -1)
1119 (forward-sexp 1))
1120 (forward-sexp 1))))
1121 1158
1122(add-to-list 1159(add-to-list
1123 'hs-special-modes-alist 1160 'hs-special-modes-alist
@@ -1144,7 +1181,7 @@ values of the functions PARSE-LHS and PARSE-RHS is returned."
1144 "Parse the field name stored in `bibtex-field-name-for-parsing'. 1181 "Parse the field name stored in `bibtex-field-name-for-parsing'.
1145If the field name is found, return a triple consisting of the position of the 1182If the field name is found, return a triple consisting of the position of the
1146very first character of the match, the actual starting position of the name 1183very first character of the match, the actual starting position of the name
1147part and end position of the match. Move point to end of field name. 1184part and end position of the match. Move point to end of field name.
1148If `bibtex-autoadd-commas' is non-nil add missing comma at end of preceeding 1185If `bibtex-autoadd-commas' is non-nil add missing comma at end of preceeding
1149BibTeX field as necessary." 1186BibTeX field as necessary."
1150 (cond ((looking-at ",[ \t\n]*") 1187 (cond ((looking-at ",[ \t\n]*")
@@ -1206,7 +1243,7 @@ end position of the field string is returned, nil otherwise."
1206The text part is either a string, or an empty string, or a constant followed 1243The text part is either a string, or an empty string, or a constant followed
1207by one or more <# (string|constant)> pairs. If a syntactically correct text 1244by one or more <# (string|constant)> pairs. If a syntactically correct text
1208is found, a pair containing the start and end position of the text is 1245is found, a pair containing the start and end position of the text is
1209returned, nil otherwise. Move point to end of field text." 1246returned, nil otherwise. Move point to end of field text."
1210 (let ((starting-point (point)) 1247 (let ((starting-point (point))
1211 end-point failure boundaries) 1248 end-point failure boundaries)
1212 (while (not (or end-point failure)) 1249 (while (not (or end-point failure))
@@ -1215,9 +1252,9 @@ returned, nil otherwise. Move point to end of field text."
1215 ((setq boundaries (bibtex-parse-field-string)) 1252 ((setq boundaries (bibtex-parse-field-string))
1216 (goto-char (cdr boundaries))) 1253 (goto-char (cdr boundaries)))
1217 ((setq failure t))) 1254 ((setq failure t)))
1218 (if (not (looking-at "[ \t\n]*#[ \t\n]*")) 1255 (if (looking-at "[ \t\n]*#[ \t\n]*")
1219 (setq end-point (point)) 1256 (goto-char (match-end 0))
1220 (goto-char (match-end 0)))) 1257 (setq end-point (point))))
1221 (if (and (not failure) 1258 (if (and (not failure)
1222 end-point) 1259 end-point)
1223 (cons starting-point end-point)))) 1260 (cons starting-point end-point))))
@@ -1234,8 +1271,8 @@ the name and text parts of the field is returned."
1234 "Search forward to find a field of name NAME. 1271 "Search forward to find a field of name NAME.
1235If a syntactically correct field is found, a pair containing the boundaries of 1272If a syntactically correct field is found, a pair containing the boundaries of
1236the name and text parts of the field is returned. The search is limited by 1273the name and text parts of the field is returned. The search is limited by
1237optional arg BOUND. If BOUND is t the search is limited by the end of the current 1274optional arg BOUND. If BOUND is t the search is limited by the end of the
1238entry. Do not move point." 1275current entry. Do not move point."
1239 (save-match-data 1276 (save-match-data
1240 (save-excursion 1277 (save-excursion
1241 (unless (integer-or-marker-p bound) 1278 (unless (integer-or-marker-p bound)
@@ -1261,8 +1298,8 @@ entry. Do not move point."
1261 "Search backward to find a field of name NAME. 1298 "Search backward to find a field of name NAME.
1262If a syntactically correct field is found, a pair containing the boundaries of 1299If a syntactically correct field is found, a pair containing the boundaries of
1263the name and text parts of the field is returned. The search is limited by 1300the name and text parts of the field is returned. The search is limited by
1264optional arg BOUND. If BOUND is t the search is limited by the beginning of the 1301optional arg BOUND. If BOUND is t the search is limited by the beginning of the
1265current entry. Do not move point." 1302current entry. Do not move point."
1266 (save-match-data 1303 (save-match-data
1267 (save-excursion 1304 (save-excursion
1268 (unless (integer-or-marker-p bound) 1305 (unless (integer-or-marker-p bound)
@@ -1294,10 +1331,15 @@ current entry. Do not move point."
1294(defsubst bibtex-end-of-text-in-field (bounds) 1331(defsubst bibtex-end-of-text-in-field (bounds)
1295 (cddr bounds)) 1332 (cddr bounds))
1296 1333
1297(defun bibtex-name-in-field (bounds) 1334(defun bibtex-name-in-field (bounds &optional remove-opt-alt)
1298 "Get content of name in BibTeX field defined via BOUNDS." 1335 "Get content of name in BibTeX field defined via BOUNDS.
1299 (buffer-substring-no-properties (nth 1 (car bounds)) 1336If optional arg REMOVE-OPT-ALT is non-nil remove \"OPT\" and \"ALT\"."
1300 (nth 2 (car bounds)))) 1337 (let ((name (buffer-substring-no-properties (nth 1 (car bounds))
1338 (nth 2 (car bounds)))))
1339 (if (and remove-opt-alt
1340 (string-match "\\`\\(OPT\\|ALT\\)" name))
1341 (substring name 3)
1342 name)))
1301 1343
1302(defun bibtex-text-in-field-bounds (bounds &optional remove-delim) 1344(defun bibtex-text-in-field-bounds (bounds &optional remove-delim)
1303 "Get content of text in BibTeX field defined via BOUNDS. 1345 "Get content of text in BibTeX field defined via BOUNDS.
@@ -1311,7 +1353,7 @@ if present."
1311 content))) 1353 content)))
1312 1354
1313(defun bibtex-text-in-field (field &optional follow-crossref) 1355(defun bibtex-text-in-field (field &optional follow-crossref)
1314 "Get content of field FIELD of current BibTeX entry. Return nil if not found. 1356 "Get content of field FIELD of current BibTeX entry. Return nil if not found.
1315If optional arg FOLLOW-CROSSREF is non-nil, follow crossref." 1357If optional arg FOLLOW-CROSSREF is non-nil, follow crossref."
1316 (save-excursion 1358 (save-excursion
1317 (save-restriction 1359 (save-restriction
@@ -1351,7 +1393,7 @@ reference key and the end position of the match."
1351 "Parse the postfix part of a BibTeX string entry, including the text. 1393 "Parse the postfix part of a BibTeX string entry, including the text.
1352If the string postfix is found, return a triple consisting of the position of 1394If the string postfix is found, return a triple consisting of the position of
1353the actual starting and ending position of the text and the very last 1395the actual starting and ending position of the text and the very last
1354character of the string entry. Move point past BibTeX string entry." 1396character of the string entry. Move point past BibTeX string entry."
1355 (let* ((case-fold-search t) 1397 (let* ((case-fold-search t)
1356 (bounds (bibtex-parse-field-text))) 1398 (bounds (bibtex-parse-field-text)))
1357 (when bounds 1399 (when bounds
@@ -1373,7 +1415,7 @@ Move point past BibTeX string entry."
1373(defun bibtex-search-forward-string () 1415(defun bibtex-search-forward-string ()
1374 "Search forward to find a BibTeX string entry. 1416 "Search forward to find a BibTeX string entry.
1375If a syntactically correct entry is found, a pair containing the boundaries of 1417If a syntactically correct entry is found, a pair containing the boundaries of
1376the reference key and text parts of the string is returned. Do not move point." 1418the reference key and text parts of the string is returned. Do not move point."
1377 (save-excursion 1419 (save-excursion
1378 (save-match-data 1420 (save-match-data
1379 (let ((case-fold-search t) 1421 (let ((case-fold-search t)
@@ -1389,7 +1431,7 @@ the reference key and text parts of the string is returned. Do not move point."
1389(defun bibtex-search-backward-string () 1431(defun bibtex-search-backward-string ()
1390 "Search backward to find a BibTeX string entry. 1432 "Search backward to find a BibTeX string entry.
1391If a syntactically correct entry is found, a pair containing the boundaries of 1433If a syntactically correct entry is found, a pair containing the boundaries of
1392the reference key and text parts of the field is returned. Do not move point." 1434the reference key and text parts of the field is returned. Do not move point."
1393 (save-excursion 1435 (save-excursion
1394 (save-match-data 1436 (save-match-data
1395 (let ((case-fold-search t) 1437 (let ((case-fold-search t)
@@ -1430,7 +1472,7 @@ delimiters if present."
1430 (match-end bibtex-type-in-head))) 1472 (match-end bibtex-type-in-head)))
1431 1473
1432(defun bibtex-key-in-head (&optional empty) 1474(defun bibtex-key-in-head (&optional empty)
1433 "Extract BibTeX key in head. Return optional arg EMPTY if key is empty." 1475 "Extract BibTeX key in head. Return optional arg EMPTY if key is empty."
1434 (if (match-beginning bibtex-key-in-head) 1476 (if (match-beginning bibtex-key-in-head)
1435 (buffer-substring-no-properties (match-beginning bibtex-key-in-head) 1477 (buffer-substring-no-properties (match-beginning bibtex-key-in-head)
1436 (match-end bibtex-key-in-head)) 1478 (match-end bibtex-key-in-head))
@@ -1438,6 +1480,10 @@ delimiters if present."
1438 1480
1439;; Helper Functions 1481;; Helper Functions
1440 1482
1483(defsubst bibtex-string= (str1 str2)
1484 "Return t if STR1 and STR2 are equal, ignoring case."
1485 (eq t (compare-strings str1 0 nil str2 0 nil t)))
1486
1441(defun bibtex-delete-whitespace () 1487(defun bibtex-delete-whitespace ()
1442 "Delete all whitespace starting at point." 1488 "Delete all whitespace starting at point."
1443 (if (looking-at "[ \t\n]+") 1489 (if (looking-at "[ \t\n]+")
@@ -1448,22 +1494,14 @@ delimiters if present."
1448 (+ (count-lines 1 (point)) 1494 (+ (count-lines 1 (point))
1449 (if (equal (current-column) 0) 1 0))) 1495 (if (equal (current-column) 0) 1 0)))
1450 1496
1451(defun bibtex-member-of-regexp (string list)
1452 "Return non-nil if STRING is exactly matched by an element of LIST.
1453The value is actually the tail of LIST whose car matches STRING."
1454 (let (case-fold-search)
1455 (while (and list
1456 (not (string-match (concat "\\`\\(?:" (car list) "\\)\\'") string)))
1457 (setq list (cdr list)))
1458 list))
1459
1460(defun bibtex-skip-to-valid-entry (&optional backward) 1497(defun bibtex-skip-to-valid-entry (&optional backward)
1461 "Unless at beginning of a valid BibTeX entry, move point to beginning of the 1498 "Move point to beginning of the next valid BibTeX entry.
1462next valid one. With optional argument BACKWARD non-nil, move backward to 1499Do not move if we are already at beginning of a valid BibTeX entry.
1463beginning of previous valid one. A valid entry is a syntactical correct one 1500With optional argument BACKWARD non-nil, move backward to
1501beginning of previous valid one. A valid entry is a syntactical correct one
1464with type contained in `bibtex-entry-field-alist' or, if 1502with type contained in `bibtex-entry-field-alist' or, if
1465`bibtex-sort-ignore-string-entries' is nil, a syntactical correct string 1503`bibtex-sort-ignore-string-entries' is nil, a syntactical correct string
1466entry. Return buffer position of beginning and ending of entry if a valid 1504entry. Return buffer position of beginning and ending of entry if a valid
1467entry is found, nil otherwise." 1505entry is found, nil otherwise."
1468 (interactive "P") 1506 (interactive "P")
1469 (let ((case-fold-search t) 1507 (let ((case-fold-search t)
@@ -1488,9 +1526,9 @@ entry is found, nil otherwise."
1488 1526
1489(defun bibtex-map-entries (fun) 1527(defun bibtex-map-entries (fun)
1490 "Call FUN for each BibTeX entry starting with the current. 1528 "Call FUN for each BibTeX entry starting with the current.
1491Do this to the end of the file. FUN is called with three arguments, the key of 1529Do this to the end of the file. FUN is called with three arguments, the key of
1492the entry and the buffer positions (marker) of beginning and end of entry. 1530the entry and the buffer positions (marker) of beginning and end of entry.
1493Point is inside the entry. If `bibtex-sort-ignore-string-entries' is non-nil, 1531Point is inside the entry. If `bibtex-sort-ignore-string-entries' is non-nil,
1494FUN will not be called for @String entries." 1532FUN will not be called for @String entries."
1495 (let ((case-fold-search t)) 1533 (let ((case-fold-search t))
1496 (bibtex-beginning-of-entry) 1534 (bibtex-beginning-of-entry)
@@ -1501,7 +1539,7 @@ FUN will not be called for @String entries."
1501 (end (copy-marker (save-excursion (bibtex-end-of-entry))))) 1539 (end (copy-marker (save-excursion (bibtex-end-of-entry)))))
1502 (save-excursion 1540 (save-excursion
1503 (if (or (and (not bibtex-sort-ignore-string-entries) 1541 (if (or (and (not bibtex-sort-ignore-string-entries)
1504 (string-equal "string" (downcase entry-type))) 1542 (bibtex-string= entry-type "string"))
1505 (assoc-string entry-type bibtex-entry-field-alist t)) 1543 (assoc-string entry-type bibtex-entry-field-alist t))
1506 (funcall fun key beg end))) 1544 (funcall fun key beg end)))
1507 (goto-char end))))) 1545 (goto-char end)))))
@@ -1556,8 +1594,8 @@ If FLAG is nil, a message is echoed if point was incremented at least
1556 1594
1557(defun bibtex-search-entry (empty-head &optional bound noerror backward) 1595(defun bibtex-search-entry (empty-head &optional bound noerror backward)
1558 "Search for a BibTeX entry (maybe without reference key if EMPTY-HEAD is t). 1596 "Search for a BibTeX entry (maybe without reference key if EMPTY-HEAD is t).
1559BOUND and NOERROR are exactly as in `re-search-forward'. If BACKWARD 1597BOUND and NOERROR are exactly as in `re-search-forward'. If BACKWARD
1560is non-nil, search is done in reverse direction. Point is moved past the 1598is non-nil, search is done in reverse direction. Point is moved past the
1561closing delimiter (at the beginning of entry if BACKWARD is non-nil). 1599closing delimiter (at the beginning of entry if BACKWARD is non-nil).
1562Return a cons pair with buffer positions of beginning and end of entry. 1600Return a cons pair with buffer positions of beginning and end of entry.
1563After call to this function MATCH-BEGINNING and MATCH-END functions 1601After call to this function MATCH-BEGINNING and MATCH-END functions
@@ -1575,7 +1613,7 @@ are defined, but only for the head part of the entry
1575 (if found 1613 (if found
1576 (progn (goto-char (match-beginning 0)) 1614 (progn (goto-char (match-beginning 0))
1577 found) 1615 found)
1578 (cond ((equal noerror nil) 1616 (cond ((not noerror)
1579 ;; yell 1617 ;; yell
1580 (error "Backward search of BibTeX entry failed")) 1618 (error "Backward search of BibTeX entry failed"))
1581 ((equal noerror t) 1619 ((equal noerror t)
@@ -1660,7 +1698,7 @@ are defined, but only for the head part of the entry
1660 (skip-chars-forward " \t\n"))) 1698 (skip-chars-forward " \t\n")))
1661 1699
1662(defun bibtex-beginning-of-first-entry () 1700(defun bibtex-beginning-of-first-entry ()
1663 "Go to the beginning of the first BibTeX entry in buffer. Return point." 1701 "Go to the beginning of the first BibTeX entry in buffer. Return point."
1664 (goto-char (point-min)) 1702 (goto-char (point-min))
1665 (if (re-search-forward "^[ \t]*@" nil 'move) 1703 (if (re-search-forward "^[ \t]*@" nil 'move)
1666 (beginning-of-line)) 1704 (beginning-of-line))
@@ -1684,10 +1722,10 @@ are defined, but only for the head part of the entry
1684 (forward-char -1))) 1722 (forward-char -1)))
1685 1723
1686(defun bibtex-enclosing-field (&optional noerr) 1724(defun bibtex-enclosing-field (&optional noerr)
1687 "Search for BibTeX field enclosing point. Point moves to end of field. 1725 "Search for BibTeX field enclosing point.
1688Use `match-beginning' and `match-end' to parse the field. If NOERR is non-nil, 1726Use `match-beginning' and `match-end' to parse the field. If NOERR is non-nil,
1689no error is signalled. In this case, bounds are returned on success, 1727no error is signalled. In this case, bounds are returned on success,
1690nil otherwise." 1728nil otherwise. Does not move point."
1691 (let ((bounds (bibtex-search-backward-field bibtex-field-name t))) 1729 (let ((bounds (bibtex-search-backward-field bibtex-field-name t)))
1692 (if (and bounds 1730 (if (and bounds
1693 (<= (bibtex-start-of-field bounds) (point)) 1731 (<= (bibtex-start-of-field bounds) (point))
@@ -1697,7 +1735,7 @@ nil otherwise."
1697 (error "Can't find enclosing BibTeX field"))))) 1735 (error "Can't find enclosing BibTeX field")))))
1698 1736
1699(defun bibtex-enclosing-entry-maybe-empty-head () 1737(defun bibtex-enclosing-entry-maybe-empty-head ()
1700 "Search for BibTeX entry enclosing point. Move point to end of entry. 1738 "Search for BibTeX entry enclosing point. Move point to end of entry.
1701Beginning (but not end) of entry is given by (`match-beginning' 0)." 1739Beginning (but not end) of entry is given by (`match-beginning' 0)."
1702 (let ((case-fold-search t) 1740 (let ((case-fold-search t)
1703 (old-point (point))) 1741 (old-point (point)))
@@ -1732,8 +1770,7 @@ Beginning (but not end) of entry is given by (`match-beginning' 0)."
1732 (message "Mark set") 1770 (message "Mark set")
1733 (bibtex-make-field (list (elt current 1) nil (elt current 2)) t)) 1771 (bibtex-make-field (list (elt current 1) nil (elt current 2)) t))
1734 ((equal bibtex-last-kill-command 'entry) 1772 ((equal bibtex-last-kill-command 'entry)
1735 (if (not (eobp)) 1773 (unless (eobp) (bibtex-beginning-of-entry))
1736 (bibtex-beginning-of-entry))
1737 (set-mark (point)) 1774 (set-mark (point))
1738 (message "Mark set") 1775 (message "Mark set")
1739 (insert (elt current 1))) 1776 (insert (elt current 1)))
@@ -1741,15 +1778,6 @@ Beginning (but not end) of entry is given by (`match-beginning' 0)."
1741 (error "Unknown tag field: %s. Please submit a bug report" 1778 (error "Unknown tag field: %s. Please submit a bug report"
1742 bibtex-last-kill-command)))))) 1779 bibtex-last-kill-command))))))
1743 1780
1744(defun bibtex-assoc-regexp (regexp alist)
1745 "Return non-nil if REGEXP matches the car of an element of ALIST.
1746The value is actually the element of ALIST matched by REGEXP.
1747Case is ignored if `case-fold-search' is non-nil in the current buffer."
1748 (while (and alist
1749 (not (string-match regexp (caar alist))))
1750 (setq alist (cdr alist)))
1751 (car alist))
1752
1753(defun bibtex-format-entry () 1781(defun bibtex-format-entry ()
1754 "Helper function for `bibtex-clean-entry'. 1782 "Helper function for `bibtex-clean-entry'.
1755Formats current entry according to variable `bibtex-entry-format'." 1783Formats current entry according to variable `bibtex-entry-format'."
@@ -1764,7 +1792,7 @@ Formats current entry according to variable `bibtex-entry-format'."
1764 unify-case inherit-booktitle) 1792 unify-case inherit-booktitle)
1765 bibtex-entry-format)) 1793 bibtex-entry-format))
1766 crossref-key bounds alternatives-there non-empty-alternative 1794 crossref-key bounds alternatives-there non-empty-alternative
1767 entry-list req-field-list field-done field-list) 1795 entry-list req-field-list field-list)
1768 1796
1769 ;; identify entry type 1797 ;; identify entry type
1770 (goto-char (point-min)) 1798 (goto-char (point-min))
@@ -1792,9 +1820,7 @@ Formats current entry according to variable `bibtex-entry-format'."
1792 ;; one alternative is non-empty 1820 ;; one alternative is non-empty
1793 (goto-char (point-min)) 1821 (goto-char (point-min))
1794 (let* ((fields-alist (bibtex-parse-entry)) 1822 (let* ((fields-alist (bibtex-parse-entry))
1795 (case-fold-search t) 1823 (field (assoc-string "crossref" fields-alist t)))
1796 (field (bibtex-assoc-regexp "\\`\\(OPT\\)?crossref\\'"
1797 fields-alist)))
1798 (setq crossref-key (and field 1824 (setq crossref-key (and field
1799 (not (string-match bibtex-empty-field-re 1825 (not (string-match bibtex-empty-field-re
1800 (cdr field))) 1826 (cdr field)))
@@ -1806,9 +1832,7 @@ Formats current entry according to variable `bibtex-entry-format'."
1806 (dolist (rfield req-field-list) 1832 (dolist (rfield req-field-list)
1807 (when (nth 3 rfield) ; we should have an alternative 1833 (when (nth 3 rfield) ; we should have an alternative
1808 (setq alternatives-there t 1834 (setq alternatives-there t
1809 field (bibtex-assoc-regexp 1835 field (assoc-string (car rfield) fields-alist t))
1810 (concat "\\`\\(ALT\\)?" (car rfield) "\\'")
1811 fields-alist))
1812 (if (and field 1836 (if (and field
1813 (not (string-match bibtex-empty-field-re 1837 (not (string-match bibtex-empty-field-re
1814 (cdr field)))) 1838 (cdr field))))
@@ -1887,7 +1911,7 @@ Formats current entry according to variable `bibtex-entry-format'."
1887 1911
1888 ;; update page dashes 1912 ;; update page dashes
1889 (if (and (memq 'page-dashes format) 1913 (if (and (memq 'page-dashes format)
1890 (string-match "\\`\\(OPT\\)?pages\\'" field-name) 1914 (bibtex-string= field-name "pages")
1891 (progn (goto-char beg-text) 1915 (progn (goto-char beg-text)
1892 (looking-at 1916 (looking-at
1893 "\\([\"{][0-9]+\\)[ \t\n]*--?[ \t\n]*\\([0-9]+[\"}]\\)"))) 1917 "\\([\"{][0-9]+\\)[ \t\n]*--?[ \t\n]*\\([0-9]+[\"}]\\)")))
@@ -1896,7 +1920,7 @@ Formats current entry according to variable `bibtex-entry-format'."
1896 ;; use book title of crossref'd entry 1920 ;; use book title of crossref'd entry
1897 (if (and (memq 'inherit-booktitle format) 1921 (if (and (memq 'inherit-booktitle format)
1898 empty-field 1922 empty-field
1899 (equal (downcase field-name) "booktitle") 1923 (bibtex-string= field-name "booktitle")
1900 crossref-key) 1924 crossref-key)
1901 (let ((title (save-restriction 1925 (let ((title (save-restriction
1902 (widen) 1926 (widen)
@@ -1909,7 +1933,7 @@ Formats current entry according to variable `bibtex-entry-format'."
1909 1933
1910 ;; Use booktitle to set a missing title. 1934 ;; Use booktitle to set a missing title.
1911 (if (and empty-field 1935 (if (and empty-field
1912 (equal (downcase field-name) "title")) 1936 (bibtex-string= field-name "title"))
1913 (let ((booktitle (bibtex-text-in-field "booktitle"))) 1937 (let ((booktitle (bibtex-text-in-field "booktitle")))
1914 (when booktitle 1938 (when booktitle
1915 (setq empty-field nil) 1939 (setq empty-field nil)
@@ -1990,8 +2014,8 @@ Formats current entry according to variable `bibtex-entry-format'."
1990(defun bibtex-autokey-abbrev (string len) 2014(defun bibtex-autokey-abbrev (string len)
1991 "Return an abbreviation of STRING with at least LEN characters. 2015 "Return an abbreviation of STRING with at least LEN characters.
1992If LEN is positive the abbreviation is terminated only after a consonant 2016If LEN is positive the abbreviation is terminated only after a consonant
1993or at the word end. If LEN is negative the abbreviation is strictly 2017or at the word end. If LEN is negative the abbreviation is strictly
1994enforced using abs (LEN) characters. If LEN is not a number, STRING 2018enforced using abs (LEN) characters. If LEN is not a number, STRING
1995is returned unchanged." 2019is returned unchanged."
1996 (cond ((or (not (numberp len)) 2020 (cond ((or (not (numberp len))
1997 (<= (length string) (abs len))) 2021 (<= (length string) (abs len)))
@@ -2007,9 +2031,9 @@ is returned unchanged."
2007 string))))) 2031 string)))))
2008 2032
2009(defun bibtex-autokey-get-field (field &optional change-list) 2033(defun bibtex-autokey-get-field (field &optional change-list)
2010 "Get content of BibTeX field FIELD. Return empty string if not found. 2034 "Get content of BibTeX field FIELD. Return empty string if not found.
2011Optional arg CHANGE-LIST is a list of substitution patterns that is 2035Optional arg CHANGE-LIST is a list of substitution patterns that is
2012applied to the content of FIELD. It is an alist with pairs 2036applied to the content of FIELD. It is an alist with pairs
2013\(OLD-REGEXP . NEW-STRING\)." 2037\(OLD-REGEXP . NEW-STRING\)."
2014 (let ((content (bibtex-text-in-field field bibtex-autokey-use-crossref)) 2038 (let ((content (bibtex-text-in-field field bibtex-autokey-use-crossref))
2015 case-fold-search) 2039 case-fold-search)
@@ -2023,15 +2047,16 @@ applied to the content of FIELD. It is an alist with pairs
2023 "Get contents of the name field of the current entry. 2047 "Get contents of the name field of the current entry.
2024Do some modifications based on `bibtex-autokey-name-change-strings' 2048Do some modifications based on `bibtex-autokey-name-change-strings'
2025and return results as a list." 2049and return results as a list."
2026 (let ((case-fold-search t)) 2050 (let ((case-fold-search t)
2027 (mapcar 'bibtex-autokey-demangle-name 2051 (names (bibtex-autokey-get-field "author\\|editor"
2028 (split-string (bibtex-autokey-get-field 2052 bibtex-autokey-name-change-strings)))
2029 "author\\|editor" 2053 ;; Some entries do not have a name field.
2030 bibtex-autokey-name-change-strings) 2054 (unless (string= "" names)
2031 "[ \t\n]+and[ \t\n]+")))) 2055 (mapcar 'bibtex-autokey-demangle-name
2056 (split-string names "[ \t\n]+and[ \t\n]+")))))
2032 2057
2033(defun bibtex-autokey-demangle-name (fullname) 2058(defun bibtex-autokey-demangle-name (fullname)
2034 "Get the last part from a well-formed name and perform abbreviations." 2059 "Get the last part from a well-formed FULLNAME and perform abbreviations."
2035 (let* (case-fold-search 2060 (let* (case-fold-search
2036 (name (cond ((string-match "\\([A-Z][^, ]*\\)[^,]*," fullname) 2061 (name (cond ((string-match "\\([A-Z][^, ]*\\)[^,]*," fullname)
2037 ;; Name is of the form "von Last, First" or 2062 ;; Name is of the form "von Last, First" or
@@ -2059,18 +2084,18 @@ and return results as a list."
2059 2084
2060(defun bibtex-autokey-get-title () 2085(defun bibtex-autokey-get-title ()
2061 "Get title field contents up to a terminator." 2086 "Get title field contents up to a terminator."
2062 (let ((titlestring 2087 (let ((case-fold-search t)
2088 (titlestring
2063 (bibtex-autokey-get-field "title" 2089 (bibtex-autokey-get-field "title"
2064 bibtex-autokey-titleword-change-strings))) 2090 bibtex-autokey-titleword-change-strings)))
2065 ;; ignore everything past a terminator 2091 ;; ignore everything past a terminator
2066 (let ((case-fold-search t)) 2092 (dolist (terminator bibtex-autokey-title-terminators)
2067 (dolist (terminator bibtex-autokey-title-terminators) 2093 (if (string-match terminator titlestring)
2068 (if (string-match terminator titlestring) 2094 (setq titlestring (substring titlestring 0 (match-beginning 0)))))
2069 (setq titlestring (substring titlestring 0 (match-beginning 0))))))
2070 ;; gather words from titlestring into a list. Ignore 2095 ;; gather words from titlestring into a list. Ignore
2071 ;; specific words and use only a specific amount of words. 2096 ;; specific words and use only a specific amount of words.
2072 (let ((counter 0) 2097 (let ((counter 0)
2073 case-fold-search titlewords titlewords-extra titleword end-match) 2098 titlewords titlewords-extra titleword end-match)
2074 (while (and (or (not (numberp bibtex-autokey-titlewords)) 2099 (while (and (or (not (numberp bibtex-autokey-titlewords))
2075 (< counter (+ bibtex-autokey-titlewords 2100 (< counter (+ bibtex-autokey-titlewords
2076 bibtex-autokey-titlewords-stretch))) 2101 bibtex-autokey-titlewords-stretch)))
@@ -2078,8 +2103,12 @@ and return results as a list."
2078 (setq end-match (match-end 0) 2103 (setq end-match (match-end 0)
2079 titleword (substring titlestring 2104 titleword (substring titlestring
2080 (match-beginning 0) end-match)) 2105 (match-beginning 0) end-match))
2081 (unless (bibtex-member-of-regexp titleword 2106 (unless (let ((lst bibtex-autokey-titleword-ignore))
2082 bibtex-autokey-titleword-ignore) 2107 (while (and lst
2108 (not (string-match (concat "\\`\\(?:" (car lst)
2109 "\\)\\'") titleword)))
2110 (setq lst (cdr lst)))
2111 lst)
2083 (setq titleword 2112 (setq titleword
2084 (funcall bibtex-autokey-titleword-case-convert titleword)) 2113 (funcall bibtex-autokey-titleword-case-convert titleword))
2085 (if (or (not (numberp bibtex-autokey-titlewords)) 2114 (if (or (not (numberp bibtex-autokey-titlewords))
@@ -2097,7 +2126,7 @@ and return results as a list."
2097 "Do some abbreviations on TITLEWORD. 2126 "Do some abbreviations on TITLEWORD.
2098The rules are defined in `bibtex-autokey-titleword-abbrevs' 2127The rules are defined in `bibtex-autokey-titleword-abbrevs'
2099and `bibtex-autokey-titleword-length'." 2128and `bibtex-autokey-titleword-length'."
2100 (let ((case-folde-search t) 2129 (let ((case-fold-search t)
2101 (alist bibtex-autokey-titleword-abbrevs)) 2130 (alist bibtex-autokey-titleword-abbrevs))
2102 (while (and alist 2131 (while (and alist
2103 (not (string-match (concat "\\`\\(?:" (caar alist) "\\)\\'") 2132 (not (string-match (concat "\\`\\(?:" (caar alist) "\\)\\'")
@@ -2119,7 +2148,7 @@ The generation algorithm works as follows:
2119 `bibtex-autokey-name-change-strings' to the corresponding new 2148 `bibtex-autokey-name-change-strings' to the corresponding new
2120 one (see documentation of this variable for further detail). 2149 one (see documentation of this variable for further detail).
2121 4. For every of at least first `bibtex-autokey-names' names in 2150 4. For every of at least first `bibtex-autokey-names' names in
2122 the name field, determine the last name. If there are maximal 2151 the name field, determine the last name. If there are maximal
2123 `bibtex-autokey-names' + `bibtex-autokey-names-stretch' 2152 `bibtex-autokey-names' + `bibtex-autokey-names-stretch'
2124 names, all names are used. 2153 names, all names are used.
2125 5. From every last name, take at least `bibtex-autokey-name-length' 2154 5. From every last name, take at least `bibtex-autokey-name-length'
@@ -2128,12 +2157,12 @@ The generation algorithm works as follows:
2128 `bibtex-autokey-name-case-convert'. 2157 `bibtex-autokey-name-case-convert'.
2129 7. Build the name part of the key by concatenating all 2158 7. Build the name part of the key by concatenating all
2130 abbreviated last names with the string 2159 abbreviated last names with the string
2131 `bibtex-autokey-name-separator' between any two. If there are 2160 `bibtex-autokey-name-separator' between any two. If there are
2132 more names than are used in the name part, prepend the string 2161 more names than are used in the name part, prepend the string
2133 contained in `bibtex-autokey-additional-names'. 2162 contained in `bibtex-autokey-additional-names'.
2134 8. Build the year part of the key by truncating the contents of 2163 8. Build the year part of the key by truncating the contents of
2135 the year field to the rightmost `bibtex-autokey-year-length' 2164 the year field to the rightmost `bibtex-autokey-year-length'
2136 digits (useful values are 2 and 4). If the year field (or any 2165 digits (useful values are 2 and 4). If the year field (or any
2137 other field required to generate the key) is absent, but the entry 2166 other field required to generate the key) is absent, but the entry
2138 has a valid crossref field and the variable 2167 has a valid crossref field and the variable
2139 `bibtex-autokey-use-crossref' is non-nil, use the field of the 2168 `bibtex-autokey-use-crossref' is non-nil, use the field of the
@@ -2149,7 +2178,7 @@ The generation algorithm works as follows:
2149 appear in `bibtex-autokey-titleword-ignore'. 2178 appear in `bibtex-autokey-titleword-ignore'.
2150 Build the title part of the key by using at least the first 2179 Build the title part of the key by using at least the first
2151 `bibtex-autokey-titlewords' words from this 2180 `bibtex-autokey-titlewords' words from this
2152 abbreviated title. If the abbreviated title ends after 2181 abbreviated title. If the abbreviated title ends after
2153 maximal `bibtex-autokey-titlewords' + 2182 maximal `bibtex-autokey-titlewords' +
2154 `bibtex-autokey-titlewords-stretch' words, all 2183 `bibtex-autokey-titlewords-stretch' words, all
2155 words from the abbreviated title are used. 2184 words from the abbreviated title are used.
@@ -2170,13 +2199,13 @@ The generation algorithm works as follows:
2170 and the title part with `bibtex-autokey-name-year-separator' 2199 and the title part with `bibtex-autokey-name-year-separator'
2171 between the name part and the year part if both are non-empty 2200 between the name part and the year part if both are non-empty
2172 and `bibtex-autokey-year-title-separator' between the year 2201 and `bibtex-autokey-year-title-separator' between the year
2173 part and the title part if both are non-empty. If the year 2202 part and the title part if both are non-empty. If the year
2174 part is empty, but not the other two parts, 2203 part is empty, but not the other two parts,
2175 `bibtex-autokey-year-title-separator' is used as well. 2204 `bibtex-autokey-year-title-separator' is used as well.
217616. If the value of `bibtex-autokey-before-presentation-function' 220516. If the value of `bibtex-autokey-before-presentation-function'
2177 is non-nil, it must be a function taking one argument. This 2206 is non-nil, it must be a function taking one argument. This
2178 function is then called with the generated key as the 2207 function is then called with the generated key as the
2179 argument. The return value of this function (a string) is 2208 argument. The return value of this function (a string) is
2180 used as the key. 2209 used as the key.
218117. If the value of `bibtex-autokey-edit-before-use' is non-nil, 221017. If the value of `bibtex-autokey-edit-before-use' is non-nil,
2182 the key is then presented in the minibuffer to the user, 2211 the key is then presented in the minibuffer to the user,
@@ -2230,9 +2259,9 @@ The generation algorithm works as follows:
2230The buffer might possibly be restricted. 2259The buffer might possibly be restricted.
2231Find both entry keys and crossref entries. 2260Find both entry keys and crossref entries.
2232If ADD is non-nil add the new keys to `bibtex-reference-keys' instead of 2261If ADD is non-nil add the new keys to `bibtex-reference-keys' instead of
2233simply resetting it. If ADD is an alist of keys, also add ADD to 2262simply resetting it. If ADD is an alist of keys, also add ADD to
2234`bibtex-reference-keys'. If ABORTABLE is non-nil abort on user 2263`bibtex-reference-keys'. If ABORTABLE is non-nil abort on user
2235input. If VERBOSE is non-nil gives messages about progress. 2264input. If VERBOSE is non-nil gives messages about progress.
2236Return alist of keys if parsing was completed, `aborted' otherwise." 2265Return alist of keys if parsing was completed, `aborted' otherwise."
2237 (let ((reference-keys (if (and add 2266 (let ((reference-keys (if (and add
2238 (listp bibtex-reference-keys)) 2267 (listp bibtex-reference-keys))
@@ -2296,8 +2325,8 @@ Return alist of keys if parsing was completed, `aborted' otherwise."
2296 "Set `bibtex-strings' to the string definitions in the whole buffer. 2325 "Set `bibtex-strings' to the string definitions in the whole buffer.
2297The buffer might possibly be restricted. 2326The buffer might possibly be restricted.
2298If ADD is non-nil add the new strings to `bibtex-strings' instead of 2327If ADD is non-nil add the new strings to `bibtex-strings' instead of
2299simply resetting it. If ADD is an alist of strings, also add ADD to 2328simply resetting it. If ADD is an alist of strings, also add ADD to
2300`bibtex-strings'. If ABORTABLE is non-nil abort on user input. 2329`bibtex-strings'. If ABORTABLE is non-nil abort on user input.
2301Return alist of strings if parsing was completed, `aborted' otherwise." 2330Return alist of strings if parsing was completed, `aborted' otherwise."
2302 (save-excursion 2331 (save-excursion
2303 (save-match-data 2332 (save-match-data
@@ -2308,7 +2337,7 @@ Return alist of strings if parsing was completed, `aborted' otherwise."
2308 bounds key) 2337 bounds key)
2309 (if (listp add) 2338 (if (listp add)
2310 (dolist (string add) 2339 (dolist (string add)
2311 (unless (assoc (car string) strings) 2340 (unless (assoc-string (car string) strings t)
2312 (push string strings)))) 2341 (push string strings))))
2313 (catch 'userkey 2342 (catch 'userkey
2314 (while (setq bounds (bibtex-search-forward-string)) 2343 (while (setq bounds (bibtex-search-forward-string))
@@ -2317,9 +2346,9 @@ Return alist of strings if parsing was completed, `aborted' otherwise."
2317 ;; user has aborted by typing a key --> return `aborted' 2346 ;; user has aborted by typing a key --> return `aborted'
2318 (throw 'userkey 'aborted)) 2347 (throw 'userkey 'aborted))
2319 (setq key (bibtex-reference-key-in-string bounds)) 2348 (setq key (bibtex-reference-key-in-string bounds))
2320 (if (not (assoc key strings)) 2349 (unless (assoc-string key strings t)
2321 (push (cons key (bibtex-text-in-string bounds t)) 2350 (push (cons key (bibtex-text-in-string bounds t))
2322 strings)) 2351 strings))
2323 (goto-char (bibtex-end-of-text-in-string bounds))) 2352 (goto-char (bibtex-end-of-text-in-string bounds)))
2324 ;; successful operation --> return `bibtex-strings' 2353 ;; successful operation --> return `bibtex-strings'
2325 (setq bibtex-strings strings)))))) 2354 (setq bibtex-strings strings))))))
@@ -2357,7 +2386,8 @@ Use `bibtex-predefined-strings' and bib files `bibtex-string-files'."
2357 (append bibtex-predefined-strings (nreverse compl))))) 2386 (append bibtex-predefined-strings (nreverse compl)))))
2358 2387
2359(defun bibtex-parse-buffers-stealthily () 2388(defun bibtex-parse-buffers-stealthily ()
2360 "Called by `bibtex-run-with-idle-timer'. Whenever emacs has been idle 2389 "Parse buffer in the background during idle time.
2390Called by `bibtex-run-with-idle-timer'. Whenever Emacs has been idle
2361for `bibtex-parse-keys-timeout' seconds, all BibTeX buffers (starting 2391for `bibtex-parse-keys-timeout' seconds, all BibTeX buffers (starting
2362with the current) are parsed." 2392with the current) are parsed."
2363 (save-excursion 2393 (save-excursion
@@ -2381,9 +2411,9 @@ with the current) are parsed."
2381 (setq buffers (cdr buffers)))))) 2411 (setq buffers (cdr buffers))))))
2382 2412
2383(defun bibtex-complete-internal (completions) 2413(defun bibtex-complete-internal (completions)
2384 "Complete word fragment before point to longest prefix of one 2414 "Complete word fragment before point to longest prefix of COMPLETIONS.
2385string defined in list COMPLETIONS. If point is not after the part 2415COMPLETIONS should be a list of strings. If point is not after the part
2386of a word, all strings are listed. Return completion." 2416of a word, all strings are listed. Return completion."
2387 (let* ((case-fold-search t) 2417 (let* ((case-fold-search t)
2388 (beg (save-excursion 2418 (beg (save-excursion
2389 (re-search-backward "[ \t{\"]") 2419 (re-search-backward "[ \t{\"]")
@@ -2409,11 +2439,12 @@ of a word, all strings are listed. Return completion."
2409 ;; return value is handled by choose-completion-string-functions 2439 ;; return value is handled by choose-completion-string-functions
2410 nil)))) 2440 nil))))
2411 2441
2412(defun bibtex-complete-string-cleanup (str) 2442(defun bibtex-complete-string-cleanup (str strings-alist)
2413 "Cleanup after inserting string STR. 2443 "Cleanup after inserting string STR.
2414Remove enclosing field delimiters for string STR. Display message with 2444Remove enclosing field delimiters for string STR. Display message with
2415expansion of STR." 2445expansion of STR using expansion list STRINGS-ALIST."
2416 (let ((pair (assoc str bibtex-strings))) 2446 (let ((pair (if (stringp str)
2447 (assoc-string str strings-alist t))))
2417 (when pair 2448 (when pair
2418 (if (cdr pair) 2449 (if (cdr pair)
2419 (message "Abbreviation for `%s'" (cdr pair))) 2450 (message "Abbreviation for `%s'" (cdr pair)))
@@ -2427,6 +2458,38 @@ expansion of STR."
2427 (bibtex-end-of-text-in-field bounds))) 2458 (bibtex-end-of-text-in-field bounds)))
2428 (bibtex-remove-delimiters)))))))) 2459 (bibtex-remove-delimiters))))))))
2429 2460
2461(defun bibtex-complete-key-cleanup (key)
2462 "Display message on entry KEY after completion of a crossref key."
2463 (save-excursion
2464 ;; Don't do anything if we completed the key of an entry.
2465 (let ((pnt (bibtex-beginning-of-entry)))
2466 (if (and (stringp key)
2467 (bibtex-find-entry key)
2468 (/= pnt (point)))
2469 (let* ((bibtex-autokey-name-case-convert 'identity)
2470 (bibtex-autokey-name-length 'infty)
2471 (nl (bibtex-autokey-get-names))
2472 (name (concat (nth 0 nl) (if (nth 1 nl) " etal")))
2473 (year (bibtex-autokey-get-field "year"))
2474 (bibtex-autokey-titlewords 5)
2475 (bibtex-autokey-titlewords-stretch 2)
2476 (bibtex-autokey-titleword-case-convert 'identity)
2477 (bibtex-autokey-titleword-length 5)
2478 (title (mapconcat 'identity
2479 (bibtex-autokey-get-title) " "))
2480 (journal (bibtex-autokey-get-field
2481 "journal" bibtex-autokey-transcriptions))
2482 (volume (bibtex-autokey-get-field "volume"))
2483 (pages (bibtex-autokey-get-field "pages" '(("-.*\\'" . "")))))
2484 (message "Ref:%s"
2485 (mapconcat (lambda (arg)
2486 (if (not (string= "" (cdr arg)))
2487 (concat (car arg) (cdr arg))))
2488 `((" " . ,name) (" " . ,year)
2489 (": " . ,title) (", " . ,journal)
2490 (" " . ,volume) (":" . ,pages))
2491 "")))))))
2492
2430(defun bibtex-choose-completion-string (choice buffer mini-p base-size) 2493(defun bibtex-choose-completion-string (choice buffer mini-p base-size)
2431 ;; Code borrowed from choose-completion-string: 2494 ;; Code borrowed from choose-completion-string:
2432 ;; We must duplicate the code from choose-completion-string 2495 ;; We must duplicate the code from choose-completion-string
@@ -2450,7 +2513,8 @@ expansion of STR."
2450 (set-window-point window (point)))) 2513 (set-window-point window (point))))
2451 2514
2452(defun bibtex-pop (arg direction) 2515(defun bibtex-pop (arg direction)
2453 "Generic function used by `bibtex-pop-previous' and `bibtex-pop-next'." 2516 "Fill current field from the ARG'th same field's text in DIRECTION.
2517Generic function used by `bibtex-pop-previous' and `bibtex-pop-next'."
2454 (let (bibtex-help-message) 2518 (let (bibtex-help-message)
2455 (bibtex-find-text nil)) 2519 (bibtex-find-text nil))
2456 (save-excursion 2520 (save-excursion
@@ -2460,17 +2524,7 @@ expansion of STR."
2460 (bounds (bibtex-enclosing-field)) 2524 (bounds (bibtex-enclosing-field))
2461 (start-old-text (bibtex-start-of-text-in-field bounds)) 2525 (start-old-text (bibtex-start-of-text-in-field bounds))
2462 (stop-old-text (bibtex-end-of-text-in-field bounds)) 2526 (stop-old-text (bibtex-end-of-text-in-field bounds))
2463 (start-name (bibtex-start-of-name-in-field bounds)) 2527 (field-name (bibtex-name-in-field bounds t)))
2464 (stop-name (bibtex-end-of-name-in-field bounds))
2465 ;; construct regexp for field with same name as this one,
2466 ;; ignoring possible OPT's or ALT's
2467 (field-name (progn
2468 (goto-char start-name)
2469 (buffer-substring-no-properties
2470 (if (looking-at "\\(OPT\\)\\|\\(ALT\\)")
2471 (match-end 0)
2472 (point))
2473 stop-name))))
2474 ;; if executed several times in a row, start each search where 2528 ;; if executed several times in a row, start each search where
2475 ;; the last one was finished 2529 ;; the last one was finished
2476 (unless (eq last-command 'bibtex-pop) 2530 (unless (eq last-command 'bibtex-pop)
@@ -2523,15 +2577,15 @@ expansion of STR."
2523General information on working with BibTeX mode: 2577General information on working with BibTeX mode:
2524 2578
2525You should use commands such as \\[bibtex-Book] to get a template for a 2579You should use commands such as \\[bibtex-Book] to get a template for a
2526specific entry. You should then fill in all desired fields using 2580specific entry. You should then fill in all desired fields using
2527\\[bibtex-next-field] to jump from field to field. After having filled 2581\\[bibtex-next-field] to jump from field to field. After having filled
2528in all desired fields in the entry, you should clean the new entry 2582in all desired fields in the entry, you should clean the new entry
2529with the command \\[bibtex-clean-entry]. 2583with the command \\[bibtex-clean-entry].
2530 2584
2531Some features of BibTeX mode are available only by setting the variable 2585Some features of BibTeX mode are available only by setting the variable
2532`bibtex-maintain-sorted-entries' to non-nil. However, then BibTeX mode will 2586`bibtex-maintain-sorted-entries' to non-nil. However, then BibTeX mode will
2533work only with buffers containing valid (syntactical correct) entries 2587work only with buffers containing valid (syntactical correct) entries
2534and with entries being sorted. This is usually the case, if you have 2588and with entries being sorted. This is usually the case, if you have
2535created a buffer completely with BibTeX mode and finished every new 2589created a buffer completely with BibTeX mode and finished every new
2536entry with \\[bibtex-clean-entry]. 2590entry with \\[bibtex-clean-entry].
2537 2591
@@ -2639,9 +2693,10 @@ non-nil.
2639 ) 2693 )
2640 nil 2694 nil
2641 (font-lock-syntactic-keywords . bibtex-font-lock-syntactic-keywords) 2695 (font-lock-syntactic-keywords . bibtex-font-lock-syntactic-keywords)
2696 (font-lock-extra-managed-props . (mouse-face keymap))
2642 (font-lock-mark-block-function 2697 (font-lock-mark-block-function
2643 . (lambda () 2698 . (lambda ()
2644 (set-mark (bibtex-end-of-entry)) 2699 (set-mark (bibtex-end-of-entry))
2645 (bibtex-beginning-of-entry))))) 2700 (bibtex-beginning-of-entry)))))
2646 (setq imenu-generic-expression 2701 (setq imenu-generic-expression
2647 (list (list nil bibtex-entry-head bibtex-key-in-head))) 2702 (list (list nil bibtex-entry-head bibtex-key-in-head)))
@@ -2681,7 +2736,7 @@ names for ENTRY-TYPE according to `bibtex-entry-field-alist'."
2681 (cons required optional))) 2736 (cons required optional)))
2682 2737
2683(defun bibtex-entry (entry-type) 2738(defun bibtex-entry (entry-type)
2684 "Insert a new BibTeX entry. 2739 "Insert a new BibTeX entry of type ENTRY-TYPE.
2685After insertion it calls the functions in `bibtex-add-entry-hook'." 2740After insertion it calls the functions in `bibtex-add-entry-hook'."
2686 (interactive (let* ((completion-ignore-case t) 2741 (interactive (let* ((completion-ignore-case t)
2687 (e-t (completing-read 2742 (e-t (completing-read
@@ -2698,8 +2753,8 @@ After insertion it calls the functions in `bibtex-add-entry-hook'."
2698 (insert "@" entry-type (bibtex-entry-left-delimiter)) 2753 (insert "@" entry-type (bibtex-entry-left-delimiter))
2699 (if key (insert key)) 2754 (if key (insert key))
2700 (save-excursion 2755 (save-excursion
2701 (mapcar 'bibtex-make-field (car field-list)) 2756 (mapc 'bibtex-make-field (car field-list))
2702 (mapcar 'bibtex-make-optional-field (cdr field-list)) 2757 (mapc 'bibtex-make-optional-field (cdr field-list))
2703 (if bibtex-comma-after-last-field 2758 (if bibtex-comma-after-last-field
2704 (insert ",")) 2759 (insert ","))
2705 (insert "\n") 2760 (insert "\n")
@@ -2722,29 +2777,27 @@ according to `bibtex-entry-field-alist', but are not yet present."
2722 (let* ((fields-alist (bibtex-parse-entry)) 2777 (let* ((fields-alist (bibtex-parse-entry))
2723 (field-list (bibtex-field-list 2778 (field-list (bibtex-field-list
2724 (substring (cdr (assoc "=type=" fields-alist)) 2779 (substring (cdr (assoc "=type=" fields-alist))
2725 1))) ; don't want @ 2780 1)))) ; don't want @
2726 (case-fold-search t))
2727 (dolist (field (car field-list)) 2781 (dolist (field (car field-list))
2728 (unless (bibtex-assoc-regexp (concat "\\`\\(ALT\\)?" (car field) "\\'") 2782 (unless (assoc-string (car field) fields-alist t)
2729 fields-alist)
2730 (bibtex-make-field field))) 2783 (bibtex-make-field field)))
2731 (dolist (field (cdr field-list)) 2784 (dolist (field (cdr field-list))
2732 (unless (bibtex-assoc-regexp (concat "\\`\\(OPT\\)?" (car field) "\\'") 2785 (unless (assoc-string (car field) fields-alist t)
2733 fields-alist)
2734 (bibtex-make-optional-field field)))))) 2786 (bibtex-make-optional-field field))))))
2735 2787
2736(defun bibtex-parse-entry () 2788(defun bibtex-parse-entry ()
2737 "Parse entry at point, return an alist. 2789 "Parse entry at point, return an alist.
2738The alist elements have the form (FIELD . TEXT), where FIELD can also be 2790The alist elements have the form (FIELD . TEXT), where FIELD can also be
2739the special strings \"=type=\" and \"=key=\". For the FIELD \"=key=\" 2791the special strings \"=type=\" and \"=key=\". For the FIELD \"=key=\"
2740TEXT may be nil. Move point to the end of the last field." 2792TEXT may be nil. Remove \"OPT\" and \"ALT\" from FIELD.
2793Move point to the end of the last field."
2741 (let (alist bounds) 2794 (let (alist bounds)
2742 (when (looking-at bibtex-entry-maybe-empty-head) 2795 (when (looking-at bibtex-entry-maybe-empty-head)
2743 (push (cons "=type=" (match-string bibtex-type-in-head)) alist) 2796 (push (cons "=type=" (match-string bibtex-type-in-head)) alist)
2744 (push (cons "=key=" (match-string bibtex-key-in-head)) alist) 2797 (push (cons "=key=" (match-string bibtex-key-in-head)) alist)
2745 (goto-char (match-end 0)) 2798 (goto-char (match-end 0))
2746 (while (setq bounds (bibtex-parse-field bibtex-field-name)) 2799 (while (setq bounds (bibtex-parse-field bibtex-field-name))
2747 (push (cons (bibtex-name-in-field bounds) 2800 (push (cons (bibtex-name-in-field bounds t)
2748 (bibtex-text-in-field-bounds bounds)) 2801 (bibtex-text-in-field-bounds bounds))
2749 alist) 2802 alist)
2750 (goto-char (bibtex-end-of-field bounds)))) 2803 (goto-char (bibtex-end-of-field bounds))))
@@ -2770,7 +2823,7 @@ TEXT may be nil. Move point to the end of the last field."
2770 (bibtex-beginning-of-entry) 2823 (bibtex-beginning-of-entry)
2771 (when (and 2824 (when (and
2772 (looking-at bibtex-entry-head) 2825 (looking-at bibtex-entry-head)
2773 (equal type (match-string bibtex-type-in-head)) 2826 (bibtex-string= type (match-string bibtex-type-in-head))
2774 ;; In case we found ourselves :-( 2827 ;; In case we found ourselves :-(
2775 (not (equal key (setq tmp (match-string bibtex-key-in-head))))) 2828 (not (equal key (setq tmp (match-string bibtex-key-in-head)))))
2776 (setq other-key tmp) 2829 (setq other-key tmp)
@@ -2780,7 +2833,7 @@ TEXT may be nil. Move point to the end of the last field."
2780 (bibtex-skip-to-valid-entry) 2833 (bibtex-skip-to-valid-entry)
2781 (when (and 2834 (when (and
2782 (looking-at bibtex-entry-head) 2835 (looking-at bibtex-entry-head)
2783 (equal type (match-string bibtex-type-in-head)) 2836 (bibtex-string= type (match-string bibtex-type-in-head))
2784 ;; In case we found ourselves :-( 2837 ;; In case we found ourselves :-(
2785 (not (equal key (setq tmp (match-string bibtex-key-in-head)))) 2838 (not (equal key (setq tmp (match-string bibtex-key-in-head))))
2786 (or (not other-key) 2839 (or (not other-key)
@@ -2794,11 +2847,8 @@ TEXT may be nil. Move point to the end of the last field."
2794 (setq other (save-excursion (goto-char other) (bibtex-parse-entry))) 2847 (setq other (save-excursion (goto-char other) (bibtex-parse-entry)))
2795 (setq key-end (point)) ;In case parse-entry changed the buffer. 2848 (setq key-end (point)) ;In case parse-entry changed the buffer.
2796 (while (setq bounds (bibtex-parse-field bibtex-field-name)) 2849 (while (setq bounds (bibtex-parse-field bibtex-field-name))
2797 (goto-char (bibtex-start-of-name-in-field bounds)) 2850 (let ((text (assoc-string (bibtex-name-in-field bounds t)
2798 (let* ((name (buffer-substring 2851 other t)))
2799 (if (looking-at "ALT\\|OPT") (match-end 0) (point))
2800 (bibtex-end-of-name-in-field bounds)))
2801 (text (assoc-string name other t)))
2802 (goto-char (bibtex-start-of-text-in-field bounds)) 2852 (goto-char (bibtex-start-of-text-in-field bounds))
2803 (if (not (and (looking-at bibtex-empty-field-re) text)) 2853 (if (not (and (looking-at bibtex-empty-field-re) text))
2804 (goto-char (bibtex-end-of-field bounds)) 2854 (goto-char (bibtex-end-of-field bounds))
@@ -2821,13 +2871,7 @@ TEXT may be nil. Move point to the end of the last field."
2821 (interactive) 2871 (interactive)
2822 (save-excursion 2872 (save-excursion
2823 (let* ((case-fold-search t) 2873 (let* ((case-fold-search t)
2824 (bounds (bibtex-enclosing-field)) 2874 (field-name (bibtex-name-in-field (bibtex-enclosing-field) t))
2825 (mb (bibtex-start-of-name-in-field bounds))
2826 (field-name (buffer-substring-no-properties
2827 (if (progn (goto-char mb)
2828 (looking-at "OPT\\|ALT"))
2829 (match-end 0) mb)
2830 (bibtex-end-of-name-in-field bounds)))
2831 (field-list (bibtex-field-list (progn (re-search-backward 2875 (field-list (bibtex-field-list (progn (re-search-backward
2832 bibtex-entry-maybe-empty-head nil t) 2876 bibtex-entry-maybe-empty-head nil t)
2833 (bibtex-type-in-head)))) 2877 (bibtex-type-in-head))))
@@ -2843,7 +2887,8 @@ TEXT may be nil. Move point to the end of the last field."
2843 "Make a field named FIELD in current BibTeX entry. 2887 "Make a field named FIELD in current BibTeX entry.
2844FIELD is either a string or a list of the form 2888FIELD is either a string or a list of the form
2845\(FIELD-NAME COMMENT-STRING INIT ALTERNATIVE-FLAG) as in 2889\(FIELD-NAME COMMENT-STRING INIT ALTERNATIVE-FLAG) as in
2846`bibtex-entry-field-alist'." 2890`bibtex-entry-field-alist'.
2891If CALLED-BY-YANK is non-nil, don't insert delimiters."
2847 (interactive 2892 (interactive
2848 (list (let ((completion-ignore-case t) 2893 (list (let ((completion-ignore-case t)
2849 (field-list (bibtex-field-list 2894 (field-list (bibtex-field-list
@@ -2868,16 +2913,16 @@ FIELD is either a string or a list of the form
2868 (indent-to-column (+ bibtex-entry-offset 2913 (indent-to-column (+ bibtex-entry-offset
2869 (- bibtex-text-indentation 2)))) 2914 (- bibtex-text-indentation 2))))
2870 (insert "= ") 2915 (insert "= ")
2871 (if (not bibtex-align-at-equal-sign) 2916 (unless bibtex-align-at-equal-sign
2872 (indent-to-column (+ bibtex-entry-offset 2917 (indent-to-column (+ bibtex-entry-offset
2873 bibtex-text-indentation))) 2918 bibtex-text-indentation)))
2874 (if (not called-by-yank) (insert (bibtex-field-left-delimiter))) 2919 (unless called-by-yank (insert (bibtex-field-left-delimiter)))
2875 (let ((init (nth 2 field))) 2920 (let ((init (nth 2 field)))
2876 (cond ((stringp init) 2921 (cond ((stringp init)
2877 (insert init)) 2922 (insert init))
2878 ((fboundp init) 2923 ((fboundp init)
2879 (insert (funcall init))))) 2924 (insert (funcall init)))))
2880 (if (not called-by-yank) (insert (bibtex-field-right-delimiter))) 2925 (unless called-by-yank (insert (bibtex-field-right-delimiter)))
2881 (when (interactive-p) 2926 (when (interactive-p)
2882 (forward-char -1) 2927 (forward-char -1)
2883 (bibtex-print-help-message))) 2928 (bibtex-print-help-message)))
@@ -2885,8 +2930,8 @@ FIELD is either a string or a list of the form
2885(defun bibtex-beginning-of-entry () 2930(defun bibtex-beginning-of-entry ()
2886 "Move to beginning of BibTeX entry (beginning of line). 2931 "Move to beginning of BibTeX entry (beginning of line).
2887If inside an entry, move to the beginning of it, otherwise move to the 2932If inside an entry, move to the beginning of it, otherwise move to the
2888beginning of the previous entry. If point is ahead of all BibTeX entries 2933beginning of the previous entry. If point is ahead of all BibTeX entries
2889move point to the beginning of buffer. Return the new location of point." 2934move point to the beginning of buffer. Return the new location of point."
2890 (interactive) 2935 (interactive)
2891 (skip-chars-forward " \t") 2936 (skip-chars-forward " \t")
2892 (if (looking-at "@") 2937 (if (looking-at "@")
@@ -2897,7 +2942,7 @@ move point to the beginning of buffer. Return the new location of point."
2897(defun bibtex-end-of-entry () 2942(defun bibtex-end-of-entry ()
2898 "Move to end of BibTeX entry (past the closing brace). 2943 "Move to end of BibTeX entry (past the closing brace).
2899If inside an entry, move to the end of it, otherwise move to the end 2944If inside an entry, move to the end of it, otherwise move to the end
2900of the previous entry. Do not move if ahead of first entry. 2945of the previous entry. Do not move if ahead of first entry.
2901Return the new location of point." 2946Return the new location of point."
2902 (interactive) 2947 (interactive)
2903 (let ((case-fold-search t) 2948 (let ((case-fold-search t)
@@ -2997,9 +3042,9 @@ If mark is active it counts entries in region, if not in whole buffer."
2997 (bibtex-end-of-entry)))) 3042 (bibtex-end-of-entry))))
2998 3043
2999(defun bibtex-entry-index () 3044(defun bibtex-entry-index ()
3000 "Return the index of the BibTeX entry at point. Move point. 3045 "Return the index of the BibTeX entry at point. Move point.
3001The index is a list (KEY CROSSREF-KEY ENTRY-NAME) that is used for sorting 3046The index is a list (KEY CROSSREF-KEY ENTRY-NAME) that is used for sorting
3002the entries of the BibTeX buffer. Return nil if no entry found." 3047the entries of the BibTeX buffer. Return nil if no entry found."
3003 (let ((case-fold-search t)) 3048 (let ((case-fold-search t))
3004 (if (re-search-forward bibtex-entry-maybe-empty-head nil t) 3049 (if (re-search-forward bibtex-entry-maybe-empty-head nil t)
3005 (let ((key (bibtex-key-in-head)) 3050 (let ((key (bibtex-key-in-head))
@@ -3049,8 +3094,8 @@ If its value is nil use plain sorting."
3049(defun bibtex-sort-buffer () 3094(defun bibtex-sort-buffer ()
3050 "Sort BibTeX buffer alphabetically by key. 3095 "Sort BibTeX buffer alphabetically by key.
3051The predicate for sorting is defined via `bibtex-maintain-sorted-entries'. 3096The predicate for sorting is defined via `bibtex-maintain-sorted-entries'.
3052If its value is nil use plain sorting. Text outside of BibTeX entries is not 3097If its value is nil use plain sorting. Text outside of BibTeX entries is not
3053affected. If `bibtex-sort-ignore-string-entries' is non-nil, @String entries 3098affected. If `bibtex-sort-ignore-string-entries' is non-nil, @String entries
3054will be ignored." 3099will be ignored."
3055 (interactive) 3100 (interactive)
3056 (save-restriction 3101 (save-restriction
@@ -3084,13 +3129,17 @@ entry."
3084 (error "This entry must not follow the crossrefed entry!")) 3129 (error "This entry must not follow the crossrefed entry!"))
3085 (goto-char pos))) 3130 (goto-char pos)))
3086 3131
3087(defun bibtex-find-entry (key) 3132(defun bibtex-find-entry (key &optional start)
3088 "Move point to the beginning of BibTeX entry named KEY. 3133 "Move point to the beginning of BibTeX entry named KEY.
3089Return position of entry if KEY is found or nil if not found." 3134Return position of entry if KEY is found or nil if not found.
3090 (interactive (list (bibtex-read-key "Find key: "))) 3135Optional arg START is buffer position where the search starts.
3136If it is nil, start search at beginning of buffer.
3137With prefix arg, the value of START is position of point."
3138 (interactive (list (bibtex-read-key "Find key: ")
3139 (if current-prefix-arg (point))))
3091 (let* (case-fold-search 3140 (let* (case-fold-search
3092 (pnt (save-excursion 3141 (pnt (save-excursion
3093 (goto-char (point-min)) 3142 (goto-char (or start (point-min)))
3094 (if (re-search-forward (concat "^[ \t]*\\(" 3143 (if (re-search-forward (concat "^[ \t]*\\("
3095 bibtex-entry-type 3144 bibtex-entry-type
3096 "\\)[ \t]*[({][ \t\n]*\\(" 3145 "\\)[ \t]*[({][ \t\n]*\\("
@@ -3108,7 +3157,7 @@ Return position of entry if KEY is found or nil if not found."
3108INDEX is a list (KEY CROSSREF-KEY ENTRY-NAME). 3157INDEX is a list (KEY CROSSREF-KEY ENTRY-NAME).
3109Move point where the entry KEY should be placed. 3158Move point where the entry KEY should be placed.
3110If `bibtex-maintain-sorted-entries' is non-nil, perform a binary 3159If `bibtex-maintain-sorted-entries' is non-nil, perform a binary
3111search to look for place for KEY. This will fail if buffer is not in 3160search to look for place for KEY. This will fail if buffer is not in
3112sorted order, see \\[bibtex-validate].) 3161sorted order, see \\[bibtex-validate].)
3113Return t if preparation was successful or nil if entry KEY already exists." 3162Return t if preparation was successful or nil if entry KEY already exists."
3114 (let ((key (nth 0 index)) 3163 (let ((key (nth 0 index))
@@ -3157,8 +3206,7 @@ Return t if preparation was successful or nil if entry KEY already exists."
3157 ;; buffer contains no valid entries or 3206 ;; buffer contains no valid entries or
3158 ;; greater than last entry --> append 3207 ;; greater than last entry --> append
3159 (bibtex-end-of-entry) 3208 (bibtex-end-of-entry)
3160 (if (not (bobp)) 3209 (unless (bobp) (newline (forward-line 2)))
3161 (newline (forward-line 2)))
3162 (beginning-of-line))))) 3210 (beginning-of-line)))))
3163 (unless key-exist t))) 3211 (unless key-exist t)))
3164 3212
@@ -3233,9 +3281,7 @@ Returns t if test was successful, nil otherwise."
3233 (goto-char (point-min)) 3281 (goto-char (point-min))
3234 (bibtex-progress-message 3282 (bibtex-progress-message
3235 "Checking required fields and month fields") 3283 "Checking required fields and month fields")
3236 (let ((bibtex-sort-ignore-string-entries t) 3284 (let ((bibtex-sort-ignore-string-entries t))
3237 (questionable-month
3238 (regexp-opt (mapcar 'car bibtex-predefined-month-strings))))
3239 (bibtex-map-entries 3285 (bibtex-map-entries
3240 (lambda (key beg end) 3286 (lambda (key beg end)
3241 (bibtex-progress-message) 3287 (bibtex-progress-message)
@@ -3251,17 +3297,16 @@ Returns t if test was successful, nil otherwise."
3251 (while (setq bounds (bibtex-search-forward-field 3297 (while (setq bounds (bibtex-search-forward-field
3252 bibtex-field-name end)) 3298 bibtex-field-name end))
3253 (goto-char (bibtex-start-of-text-in-field bounds)) 3299 (goto-char (bibtex-start-of-text-in-field bounds))
3254 (let ((field-name (downcase (bibtex-name-in-field bounds))) 3300 (let ((field-name (bibtex-name-in-field bounds)))
3255 case-fold-search) 3301 (if (and (bibtex-string= field-name "month")
3256 (if (and (equal field-name "month") 3302 (not (assoc-string (bibtex-text-in-field-bounds bounds)
3257 (not (string-match questionable-month 3303 bibtex-predefined-month-strings t)))
3258 (bibtex-text-in-field-bounds bounds))))
3259 (push (list (bibtex-current-line) 3304 (push (list (bibtex-current-line)
3260 "Questionable month field") 3305 "Questionable month field")
3261 error-list)) 3306 error-list))
3262 (setq req (delete (assoc-string field-name req t) req) 3307 (setq req (delete (assoc-string field-name req t) req)
3263 creq (delete (assoc-string field-name creq t) creq)) 3308 creq (delete (assoc-string field-name creq t) creq))
3264 (if (equal field-name "crossref") 3309 (if (bibtex-string= field-name "crossref")
3265 (setq crossref-there t)))) 3310 (setq crossref-there t))))
3266 (if crossref-there 3311 (if crossref-there
3267 (setq req creq)) 3312 (setq req creq))
@@ -3305,10 +3350,6 @@ Returns t if test was successful, nil otherwise."
3305 (dolist (err error-list) 3350 (dolist (err error-list)
3306 (insert bufnam ":" (number-to-string (elt err 0)) 3351 (insert bufnam ":" (number-to-string (elt err 0))
3307 ": " (elt err 1) "\n")) 3352 ": " (elt err 1) "\n"))
3308 (compilation-parse-errors nil nil)
3309 (setq compilation-old-error-list compilation-error-list)
3310 ;; this is necessary to avoid reparsing of buffer if you
3311 ;; switch to compilation buffer and enter `compile-goto-error'
3312 (set-buffer-modified-p nil) 3353 (set-buffer-modified-p nil)
3313 (toggle-read-only 1) 3354 (toggle-read-only 1)
3314 (goto-char (point-min)) 3355 (goto-char (point-min))
@@ -3395,11 +3436,13 @@ Align text and go thereafter to end of text."
3395 (interactive) 3436 (interactive)
3396 (save-excursion 3437 (save-excursion
3397 (bibtex-inside-field) 3438 (bibtex-inside-field)
3398 (let ((bounds (bibtex-enclosing-field))) 3439 (let* ((bounds (bibtex-enclosing-field))
3399 (goto-char (bibtex-start-of-text-in-field bounds)) 3440 (end (bibtex-end-of-text-in-field bounds))
3400 (delete-char 1) 3441 (start (bibtex-start-of-text-in-field bounds)))
3401 (goto-char (1- (bibtex-end-of-text-in-field bounds))) 3442 (if (memq (char-before end) '(?\} ?\"))
3402 (delete-backward-char 1)))) 3443 (delete-region (1- end) end))
3444 (if (memq (char-after start) '(?\{ ?\"))
3445 (delete-region start (1+ start))))))
3403 3446
3404(defun bibtex-kill-field (&optional copy-only) 3447(defun bibtex-kill-field (&optional copy-only)
3405 "Kill the entire enclosing BibTeX field. 3448 "Kill the entire enclosing BibTeX field.
@@ -3455,6 +3498,7 @@ With prefix arg COPY-ONLY the current entry to
3455 (setq bibtex-last-kill-command 'entry)) 3498 (setq bibtex-last-kill-command 'entry))
3456 3499
3457(defun bibtex-copy-entry-as-kill () 3500(defun bibtex-copy-entry-as-kill ()
3501 "Copy the entire enclosing BibTeX entry to `bibtex-entry-kill-ring'."
3458 (interactive) 3502 (interactive)
3459 (bibtex-kill-entry t)) 3503 (bibtex-kill-entry t))
3460 3504
@@ -3482,8 +3526,8 @@ If N is negative, this is a more recent kill.
3482The sequence of kills wraps around, so that after the oldest one 3526The sequence of kills wraps around, so that after the oldest one
3483comes the newest one." 3527comes the newest one."
3484 (interactive "*p") 3528 (interactive "*p")
3485 (if (not (eq last-command 'bibtex-yank)) 3529 (unless (eq last-command 'bibtex-yank)
3486 (error "Previous command was not a BibTeX yank")) 3530 (error "Previous command was not a BibTeX yank"))
3487 (setq this-command 'bibtex-yank) 3531 (setq this-command 'bibtex-yank)
3488 (let ((inhibit-read-only t)) 3532 (let ((inhibit-read-only t))
3489 (delete-region (point) (mark t)) 3533 (delete-region (point) (mark t))
@@ -3519,7 +3563,7 @@ intermixed with \\[bibtex-pop-previous] (bibtex-pop-previous)."
3519Check that no required fields are empty and formats entry dependent 3563Check that no required fields are empty and formats entry dependent
3520on the value of `bibtex-entry-format'. 3564on the value of `bibtex-entry-format'.
3521If the reference key of the entry is empty or a prefix argument is given, 3565If the reference key of the entry is empty or a prefix argument is given,
3522calculate a new reference key. (Note: this will only work if fields in entry 3566calculate a new reference key. (Note: this will only work if fields in entry
3523begin on separate lines prior to calling `bibtex-clean-entry' or if 3567begin on separate lines prior to calling `bibtex-clean-entry' or if
3524'realign is contained in `bibtex-entry-format'.) 3568'realign is contained in `bibtex-entry-format'.)
3525Don't call `bibtex-clean-entry' on @Preamble entries. 3569Don't call `bibtex-clean-entry' on @Preamble entries.
@@ -3533,19 +3577,20 @@ At end of the cleaning process, the functions in
3533 (bibtex-beginning-of-entry) 3577 (bibtex-beginning-of-entry)
3534 (save-excursion 3578 (save-excursion
3535 (when (re-search-forward bibtex-entry-maybe-empty-head nil t) 3579 (when (re-search-forward bibtex-entry-maybe-empty-head nil t)
3536 (setq entry-type (downcase (bibtex-type-in-head))) 3580 (setq entry-type (bibtex-type-in-head))
3537 (setq key (bibtex-key-in-head)))) 3581 (setq key (bibtex-key-in-head))))
3538 ;; formatting 3582 ;; formatting
3539 (cond ((equal entry-type "preamble") 3583 (cond ((bibtex-string= entry-type "preamble")
3540 ;; (bibtex-format-preamble) 3584 ;; (bibtex-format-preamble)
3541 (error "No clean up of @Preamble entries")) 3585 (error "No clean up of @Preamble entries"))
3542 ((equal entry-type "string")) 3586 ((bibtex-string= entry-type "string"))
3543 ;; (bibtex-format-string) 3587 ;; (bibtex-format-string)
3544 (t (bibtex-format-entry))) 3588 (t (bibtex-format-entry)))
3545 ;; set key 3589 ;; set key
3546 (when (or new-key (not key)) 3590 (when (or new-key (not key))
3547 (setq key (bibtex-generate-autokey)) 3591 (setq key (bibtex-generate-autokey))
3548 (if bibtex-autokey-edit-before-use 3592 ;; Sometimes bibtex-generate-autokey returns an empty string
3593 (if (or bibtex-autokey-edit-before-use (string= "" key))
3549 (setq key (bibtex-read-key "Key to use: " key))) 3594 (setq key (bibtex-read-key "Key to use: " key)))
3550 (re-search-forward bibtex-entry-maybe-empty-head) 3595 (re-search-forward bibtex-entry-maybe-empty-head)
3551 (if (match-beginning bibtex-key-in-head) 3596 (if (match-beginning bibtex-key-in-head)
@@ -3563,19 +3608,21 @@ At end of the cleaning process, the functions in
3563 (entry (buffer-substring start end)) 3608 (entry (buffer-substring start end))
3564 (index (progn (goto-char start) 3609 (index (progn (goto-char start)
3565 (bibtex-entry-index))) 3610 (bibtex-entry-index)))
3566 no-error) 3611 error)
3567 (if (and bibtex-maintain-sorted-entries 3612 (if (and bibtex-maintain-sorted-entries
3568 (not (and bibtex-sort-ignore-string-entries 3613 (not (and bibtex-sort-ignore-string-entries
3569 (equal entry-type "string")))) 3614 (bibtex-string= entry-type "string"))))
3570 (progn 3615 (progn
3571 (delete-region start end) 3616 (delete-region start end)
3572 (setq no-error (bibtex-prepare-new-entry index)) 3617 (setq error (not (bibtex-prepare-new-entry index)))
3573 (insert entry) 3618 (insert entry)
3574 (forward-char -1) 3619 (forward-char -1)
3575 (bibtex-beginning-of-entry) ; moves backward 3620 (bibtex-beginning-of-entry) ; moves backward
3576 (re-search-forward bibtex-entry-head)) 3621 (re-search-forward bibtex-entry-head))
3577 (setq no-error (bibtex-find-entry (car index)))) 3622 (bibtex-find-entry key)
3578 (unless no-error 3623 (setq error (or (/= (point) start)
3624 (bibtex-find-entry key end))))
3625 (if error
3579 (error "New inserted entry yields duplicate key")))) 3626 (error "New inserted entry yields duplicate key"))))
3580 ;; final clean up 3627 ;; final clean up
3581 (unless called-by-reformat 3628 (unless called-by-reformat
@@ -3583,7 +3630,7 @@ At end of the cleaning process, the functions in
3583 (save-restriction 3630 (save-restriction
3584 (bibtex-narrow-to-entry) 3631 (bibtex-narrow-to-entry)
3585 ;; Only update the list of keys if it has been built already. 3632 ;; Only update the list of keys if it has been built already.
3586 (cond ((equal entry-type "string") 3633 (cond ((bibtex-string= entry-type "string")
3587 (if (listp bibtex-strings) (bibtex-parse-strings t))) 3634 (if (listp bibtex-strings) (bibtex-parse-strings t)))
3588 ((listp bibtex-reference-keys) (bibtex-parse-keys t))) 3635 ((listp bibtex-reference-keys) (bibtex-parse-keys t)))
3589 (run-hooks 'bibtex-clean-entry-hook)))))) 3636 (run-hooks 'bibtex-clean-entry-hook))))))
@@ -3752,28 +3799,29 @@ entries from minibuffer."
3752(defun bibtex-complete () 3799(defun bibtex-complete ()
3753 "Complete word fragment before point according to context. 3800 "Complete word fragment before point according to context.
3754If point is inside key or crossref field perform key completion based on 3801If point is inside key or crossref field perform key completion based on
3755`bibtex-reference-keys'. Inside any other field perform string 3802`bibtex-reference-keys'. Inside a month field perform key completion
3756completion based on `bibtex-strings'. An error is signaled if point 3803based on `bibtex-predefined-month-strings'. Inside any other field
3757is outside key or BibTeX field." 3804perform string completion based on `bibtex-strings'. An error is
3805signaled if point is outside key or BibTeX field."
3758 (interactive) 3806 (interactive)
3759 (let* ((pnt (point)) 3807 (let ((pnt (point))
3760 (case-fold-search t) 3808 (case-fold-search t)
3761 bounds compl) 3809 bounds name compl)
3762 (save-excursion 3810 (save-excursion
3763 (if (and (setq bounds (bibtex-enclosing-field t)) 3811 (if (and (setq bounds (bibtex-enclosing-field t))
3764 (>= pnt (bibtex-start-of-text-in-field bounds)) 3812 (>= pnt (bibtex-start-of-text-in-field bounds))
3765 (<= pnt (bibtex-end-of-text-in-field bounds))) 3813 (<= pnt (bibtex-end-of-text-in-field bounds)))
3766 (progn 3814 (setq name (bibtex-name-in-field bounds t)
3767 (goto-char (bibtex-start-of-name-in-field bounds)) 3815 compl (cond ((bibtex-string= name "crossref")
3768 (setq compl (if (string= "crossref" 3816 'key)
3769 (downcase 3817 ((bibtex-string= name "month")
3770 (buffer-substring-no-properties 3818 bibtex-predefined-month-strings)
3771 (if (looking-at "\\(OPT\\)\\|\\(ALT\\)") 3819 (t (if (listp bibtex-strings)
3772 (match-end 0) 3820 bibtex-strings
3773 (point)) 3821 ;; so that bibtex-complete-string-cleanup
3774 (bibtex-end-of-name-in-field bounds)))) 3822 ;; can do its job
3775 'key 3823 (bibtex-parse-strings
3776 'str))) 3824 (bibtex-string-files-init))))))
3777 (bibtex-beginning-of-entry) 3825 (bibtex-beginning-of-entry)
3778 (if (and (re-search-forward bibtex-entry-maybe-empty-head nil t) 3826 (if (and (re-search-forward bibtex-entry-maybe-empty-head nil t)
3779 ;; point is inside a key 3827 ;; point is inside a key
@@ -3789,24 +3837,23 @@ is outside key or BibTeX field."
3789 ;; key completion 3837 ;; key completion
3790 (setq choose-completion-string-functions 3838 (setq choose-completion-string-functions
3791 (lambda (choice buffer mini-p base-size) 3839 (lambda (choice buffer mini-p base-size)
3792 (bibtex-choose-completion-string choice buffer mini-p base-size) 3840 (bibtex-choose-completion-string choice buffer mini-p base-size)
3793 (if bibtex-complete-key-cleanup 3841 (bibtex-complete-key-cleanup choice)
3794 (funcall bibtex-complete-key-cleanup choice))
3795 ;; return t (required by choose-completion-string-functions) 3842 ;; return t (required by choose-completion-string-functions)
3796 t)) 3843 t))
3797 (let ((choice (bibtex-complete-internal bibtex-reference-keys))) 3844 (bibtex-complete-key-cleanup (bibtex-complete-internal
3798 (if bibtex-complete-key-cleanup 3845 bibtex-reference-keys)))
3799 (funcall bibtex-complete-key-cleanup choice))))
3800 3846
3801 ((equal compl 'str) 3847 (compl
3802 ;; string completion 3848 ;; string completion
3803 (setq choose-completion-string-functions 3849 (setq choose-completion-string-functions
3804 (lambda (choice buffer mini-p base-size) 3850 `(lambda (choice buffer mini-p base-size)
3805 (bibtex-choose-completion-string choice buffer mini-p base-size) 3851 (bibtex-choose-completion-string choice buffer mini-p base-size)
3806 (bibtex-complete-string-cleanup choice) 3852 (bibtex-complete-string-cleanup choice ',compl)
3807 ;; return t (required by choose-completion-string-functions) 3853 ;; return t (required by choose-completion-string-functions)
3808 t)) 3854 t))
3809 (bibtex-complete-string-cleanup (bibtex-complete-internal bibtex-strings))) 3855 (bibtex-complete-string-cleanup (bibtex-complete-internal compl)
3856 compl))
3810 3857
3811 (t (error "Point outside key or BibTeX field"))))) 3858 (t (error "Point outside key or BibTeX field")))))
3812 3859
@@ -3880,8 +3927,8 @@ is outside key or BibTeX field."
3880 (interactive (list (completing-read "String key: " bibtex-strings 3927 (interactive (list (completing-read "String key: " bibtex-strings
3881 nil nil nil 'bibtex-key-history))) 3928 nil nil nil 'bibtex-key-history)))
3882 (let ((bibtex-maintain-sorted-entries 3929 (let ((bibtex-maintain-sorted-entries
3883 (if (not bibtex-sort-ignore-string-entries) 3930 (unless bibtex-sort-ignore-string-entries
3884 bibtex-maintain-sorted-entries)) 3931 bibtex-maintain-sorted-entries))
3885 endpos) 3932 endpos)
3886 (unless (bibtex-prepare-new-entry (list key nil "String")) 3933 (unless (bibtex-prepare-new-entry (list key nil "String"))
3887 (error "Entry with key `%s' already exists" key)) 3934 (error "Entry with key `%s' already exists" key))
@@ -3913,6 +3960,81 @@ is outside key or BibTeX field."
3913 "\n") 3960 "\n")
3914 (goto-char endpos))) 3961 (goto-char endpos)))
3915 3962
3963(defun bibtex-url (&optional event)
3964 "Browse a URL for the BibTeX entry at position PNT.
3965The URL is generated using the schemes defined in `bibtex-generate-url-list'
3966\(see there\). Then the URL is passed to `browse-url'."
3967 (interactive (list last-input-event))
3968 (save-excursion
3969 (if event (posn-set-point (event-end event)))
3970 (bibtex-beginning-of-entry)
3971 (let ((fields-alist (bibtex-parse-entry))
3972 (case-fold-search t)
3973 (lst bibtex-generate-url-list)
3974 field url scheme)
3975 (while (setq scheme (car lst))
3976 (when (and (setq field (cdr (assoc-string (caar scheme)
3977 fields-alist t)))
3978 (progn
3979 (if (string-match "\\`[{\"]\\(.*\\)[}\"]\\'" field)
3980 (setq field (match-string 1 field)))
3981 (string-match (cdar scheme) field)))
3982 (setq lst nil)
3983 (if (null (cdr scheme))
3984 (setq url (match-string 0 field)))
3985 (dolist (step (cdr scheme))
3986 (cond ((stringp step)
3987 (setq url (concat url step)))
3988 ((setq field (assoc-string (car step) fields-alist t))
3989 ;; always remove field delimiters
3990 (let* ((text (if (string-match "\\`[{\"]\\(.*\\)[}\"]\\'"
3991 (cdr field))
3992 (match-string 1 (cdr field))
3993 (cdr field)))
3994 (str (if (string-match (nth 1 step) text)
3995 (cond
3996 ((functionp (nth 2 step))
3997 (funcall (nth 2 step) text))
3998 ((numberp (nth 2 step))
3999 (match-string (nth 2 step) text))
4000 (t
4001 (replace-match (nth 2 step) nil nil text)))
4002 ;; If the scheme is set up correctly,
4003 ;; we should never reach this point
4004 (error "Match failed: %s" text))))
4005 (setq url (concat url str))))
4006 ;; If the scheme is set up correctly,
4007 ;; we should never reach this point
4008 (t (error "Step failed: %s" step))))
4009 (message "%s" url)
4010 (browse-url url))
4011 (setq lst (cdr lst)))
4012 (unless url (message "No URL known.")))))
4013
4014(defun bibtex-font-lock-url (bound)
4015 "Font-lock for URLs."
4016 (let ((case-fold-search t)
4017 (bounds (bibtex-enclosing-field t))
4018 (pnt (point))
4019 found field)
4020 ;; We use start-of-field as syntax-begin
4021 (goto-char (if bounds (bibtex-start-of-field bounds) pnt))
4022 (while (and (not found)
4023 (prog1 (re-search-forward bibtex-font-lock-url-regexp bound t)
4024 (setq field (match-string-no-properties 1)))
4025 (setq bounds (bibtex-parse-field-text))
4026 (>= bound (car bounds))
4027 (>= (car bounds) pnt))
4028 (let ((lst bibtex-generate-url-list) url)
4029 (goto-char (car bounds))
4030 (while (and (not found)
4031 (setq url (caar lst)))
4032 (when (bibtex-string= field (car url))
4033 (setq found (re-search-forward (cdr url) (cdr bounds) t)))
4034 (setq lst (cdr lst))))
4035 (goto-char (cdr bounds)))
4036 found))
4037
3916 4038
3917;; Make BibTeX a Feature 4039;; Make BibTeX a Feature
3918 4040
diff --git a/lisp/textmodes/dns-mode.el b/lisp/textmodes/dns-mode.el
new file mode 100644
index 00000000000..400f87205c4
--- /dev/null
+++ b/lisp/textmodes/dns-mode.el
@@ -0,0 +1,198 @@
1;;; dns-mode.el --- a mode for viewing/editing Domain Name System master files
2;; Copyright (c) 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
3
4;; Author: Simon Josefsson <simon@josefsson.org>
5;; Keywords: DNS master zone file SOA
6
7;; This file is part of GNU Emacs.
8
9;; GNU Emacs is free software; you can redistribute it and/or modify
10;; it under the terms of the GNU General Public License as published by
11;; the Free Software Foundation; either version 2, or (at your option)
12;; any later version.
13
14;; GNU Emacs is distributed in the hope that it will be useful,
15;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17;; GNU General Public License for more details.
18
19;; You should have received a copy of the GNU General Public License
20;; along with GNU Emacs; see the file COPYING. If not, write to the
21;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22;; Boston, MA 02111-1307, USA.
23
24;;; Commentary:
25
26;; Use M-x dns-mode RET to invoke in master files.
27;;
28;; C-c C-s Increment SOA serial.
29;; Understands YYYYMMDDNN, Unix time, and serial number formats,
30;; and complains if it fail to find SOA serial.
31;;
32;; Put something similar to the following in your ~/.emacs to use this file:
33;;
34;; (load "~/path/to/dns-mode.el")
35;; (setq auto-mode-alist (cons '("\\.soa\\'" . dns-mode) auto-mode-alist))
36
37;;; References:
38
39;; RFC 1034, "DOMAIN NAMES - CONCEPTS AND FACILITIES", P. Mockapetris.
40;; RFC 1035, "DOMAIN NAMES - IMPLEMENTATION AND SPECIFICATION", P. Mockapetris.
41
42;;; Release history:
43
44;; 2004-09-11 Posted on gnu.emacs.sources.
45;; 2004-09-13 Ported to XEmacs.
46;; 2004-09-14 Installed in Emacs CVS.
47
48;;; Code:
49
50(defgroup dns-mode nil
51 "DNS master file mode configuration.")
52
53(defconst dns-mode-classes '("IN" "CS" "CH" "HS")
54 "List of strings with known DNS classes.")
55
56(defconst dns-mode-types '("A" "NS" "MD" "MF" "CNAME" "SOA" "MB" "MG" "MR"
57 "NULL" "WKS" "PTR" "HINFO" "MINFO" "MX" "TXT"
58 "RP" "AFSDB" "X25" "ISDN" "RT" "NSAP" "NSAP"
59 "SIG" "KEY" "PX" "GPOS" "AAAA" "LOC" "NXT"
60 "EID" "NIMLOC" "SRV" "ATMA" "NAPTR" "KX" "CERT"
61 "A6" "DNAME" "SINK" "OPT" "APL" "DS" "SSHFP"
62 "RRSIG" "NSEC" "DNSKEY" "UINFO" "UID" "GID"
63 "UNSPEC" "TKEY" "TSIG" "IXFR" "AXFR" "MAILB"
64 "MAILA")
65 "List of strings with known DNS types.")
66
67;; Font lock.
68
69(defvar dns-mode-control-entity-face 'font-lock-keyword-face
70 "Name of face used for control entities, e.g. $ORIGIN.")
71
72(defvar dns-mode-bad-control-entity-face 'font-lock-warning-face
73 "Name of face used for non-standard control entities, e.g. $FOO.")
74
75(defvar dns-mode-type-face 'font-lock-type-face
76 "Name of face used for DNS types, e.g., SOA.")
77
78(defvar dns-mode-class-face 'font-lock-constant-face
79 "Name of face used for DNS classes, e.g., IN.")
80
81(defcustom dns-mode-font-lock-keywords
82 `(("^$ORIGIN" 0 ,dns-mode-control-entity-face)
83 ("^$INCLUDE" 0 ,dns-mode-control-entity-face)
84 ("^$[a-z0-9A-Z]+" 0 ,dns-mode-bad-control-entity-face)
85 (,(regexp-opt dns-mode-classes) 0 ,dns-mode-class-face)
86 (,(regexp-opt dns-mode-types) 0 ,dns-mode-type-face))
87 "Font lock keywords used to highlight text in DNS master file mode."
88 :type 'sexp
89 :group 'dns-mode)
90
91;; Syntax table.
92
93(defvar dns-mode-syntax-table
94 (let ((table (make-syntax-table)))
95 (modify-syntax-entry ?\; "< " table)
96 (modify-syntax-entry ?\n "> " table)
97 table)
98 "Syntax table in use in DNS master file buffers.")
99
100;; Keymap.
101
102(defvar dns-mode-map
103 (let ((map (make-sparse-keymap)))
104 (define-key map "\C-c\C-s" 'dns-mode-soa-increment-serial)
105 map)
106 "Keymap for DNS master file mode.")
107
108;; Menu.
109
110(defvar dns-mode-menu nil
111 "Menubar used in DNS master file mode.")
112
113(easy-menu-define dns-mode-menu dns-mode-map
114 "DNS Menu."
115 '("DNS"
116 ["Increment SOA serial" dns-mode-soa-increment-serial t]))
117
118;; Mode.
119
120;;;###autoload
121(define-derived-mode dns-mode text-mode "DNS"
122 "Major mode for viewing and editing DNS master files.
123This mode is inherited from text mode. It add syntax
124highlighting, and some commands for handling DNS master files.
125Its keymap inherits from `text-mode' and it has the same
126variables for customizing indentation. It has its own abbrev
127table and its own syntax table.
128
129Turning on DNS mode runs `dns-mode-hook'."
130 (set (make-local-variable 'comment-start) ";")
131 (set (make-local-variable 'comment-end) "")
132 (set (make-local-variable 'comment-start-skip) ";+ *")
133 (unless (featurep 'xemacs)
134 (set (make-local-variable 'font-lock-defaults)
135 '(dns-mode-font-lock-keywords nil nil ((?_ . "w")))))
136 (easy-menu-add dns-mode-menu dns-mode-map))
137
138;; Tools.
139
140;;;###autoload
141(defun dns-mode-soa-increment-serial ()
142 "Locate SOA record and increment the serial field."
143 (interactive)
144 (save-excursion
145 (goto-char (point-min))
146 (unless (re-search-forward
147 (concat "^\\(\\(\\([^ \t]+[ \t]+\\)?[^ \t]+"
148 "[ \t]+\\)?[^ \t]+[ \t]+\\)?SOA") nil t)
149 (error "Cannot locate SOA record"))
150 (if (re-search-forward (concat "\\<\\("
151 ;; year
152 "\\(198\\|199\\|20[0-9]\\)[0-9]"
153 ;; month
154 "\\(0[0-9]\\|10\\|11\\|12\\)"
155 ;; day
156 "\\([012][0-9]\\|30\\|31\\)"
157 ;; counter
158 "\\([0-9]\\{1,3\\}\\)"
159 "\\)\\>")
160 nil t)
161 ;; YYYYMMDDIII format, one to three I's.
162 (let* ((serial (match-string 1))
163 (counterstr (match-string 5))
164 (counter (string-to-number counterstr))
165 (now (format-time-string "%Y%m%d"))
166 (nowandoldserial (concat now counterstr)))
167 (if (string< serial nowandoldserial)
168 (let ((new (format "%s00" now)))
169 (replace-match new nil nil nil 1)
170 (message "Replaced old serial %s with %s" serial new))
171 (if (string= serial nowandoldserial)
172 (let ((new (format (format "%%s%%0%dd" (length counterstr))
173 now (1+ counter))))
174 (replace-match new nil nil nil 1)
175 (message "Replaced old serial %s with %s" serial new))
176 (error "Current SOA serial is in the future"))))
177 (if (re-search-forward "\\<\\([0-9]\\{9,10\\}\\)\\>" nil t)
178 ;; Unix time
179 (let* ((serial (match-string 1))
180 (new (format-time-string "%s")))
181 (if (not (string< serial new))
182 (error "Current SOA serial is in the future")
183 (replace-match new nil nil nil 1)
184 (message "Replaced old serial %s with %s" serial new)))
185 (if (re-search-forward "\\<\\([0-9]+\\)\\>" nil t)
186 ;; Just any serial number.
187 (let* ((serial (match-string 1))
188 (new (format "%d" (1+ (string-to-number serial)))))
189 (replace-match new nil nil nil 1)
190 (message "Replaced old serial %s with %s" serial new))
191 (error "Cannot locate serial number in SOA record"))))))
192
193;;;###autoload(add-to-list 'auto-mode-alist '("\\.soa\\'" . dns-mode))
194
195(provide 'dns-mode)
196
197;; arch-tag: 6a179f0a-072f-49db-8b01-37b8f23998c0
198;;; dns-mode.el ends here
diff --git a/lisp/vc-arch.el b/lisp/vc-arch.el
index c4c484a9347..e32fc474d94 100644
--- a/lisp/vc-arch.el
+++ b/lisp/vc-arch.el
@@ -73,18 +73,10 @@
73(put 'Arch 'vc-functions nil) 73(put 'Arch 'vc-functions nil)
74 74
75;;;###autoload (defun vc-arch-registered (file) 75;;;###autoload (defun vc-arch-registered (file)
76;;;###autoload (let ((dir file)) 76;;;###autoload (if (vc-find-root file "{arch}/=tagging-method")
77;;;###autoload (while (and (stringp dir) 77;;;###autoload (progn
78;;;###autoload (not (equal 78;;;###autoload (load "vc-arch")
79;;;###autoload dir (setq dir (file-name-directory dir)))) 79;;;###autoload (vc-arch-registered file))))
80;;;###autoload dir)
81;;;###autoload (setq dir (if (file-directory-p
82;;;###autoload (expand-file-name "{arch}" dir))
83;;;###autoload t (directory-file-name dir))))
84;;;###autoload (if (eq dir t)
85;;;###autoload (progn
86;;;###autoload (load "vc-arch")
87;;;###autoload (vc-arch-registered file)))))
88 80
89(defun vc-arch-add-tagline () 81(defun vc-arch-add-tagline ()
90 "Add an `arch-tag' to the end of the current file." 82 "Add an `arch-tag' to the end of the current file."
@@ -186,18 +178,10 @@ Only the value `maybe' can be trusted :-(."
186(defun vc-arch-root (file) 178(defun vc-arch-root (file)
187 "Return the root directory of a Arch project, if any." 179 "Return the root directory of a Arch project, if any."
188 (or (vc-file-getprop file 'arch-root) 180 (or (vc-file-getprop file 'arch-root)
189 (vc-file-setprop 181 (vc-file-setprop
190 file 'arch-root 182 ;; Check the =tagging-method, in case someone naively manually
191 (let ((root nil)) 183 ;; creates a {arch} directory somewhere.
192 (while (not (or root 184 file 'arch-root (vc-find-root file "{arch}/=tagging-method"))))
193 (equal file (setq file (file-name-directory file)))
194 (null file)))
195 ;; Check the =tagging-method, in case someone naively manually
196 ;; creates a {arch} directory somewhere.
197 (if (file-exists-p (expand-file-name "{arch}/=tagging-method" file))
198 (setq root file)
199 (setq file (directory-file-name file))))
200 root))))
201 185
202(defun vc-arch-register (file &optional rev comment) 186(defun vc-arch-register (file &optional rev comment)
203 (if rev (error "Explicit initial revision not supported for Arch")) 187 (if rev (error "Explicit initial revision not supported for Arch"))
diff --git a/lisp/vc-hooks.el b/lisp/vc-hooks.el
index 3f5a46c5bea..fef1431fe7d 100644
--- a/lisp/vc-hooks.el
+++ b/lisp/vc-hooks.el
@@ -1,6 +1,6 @@
1;;; vc-hooks.el --- resident support for version-control 1;;; vc-hooks.el --- resident support for version-control
2 2
3;; Copyright (C) 1992,93,94,95,96,98,99,2000,03,2004 3;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2003, 2004
4;; Free Software Foundation, Inc. 4;; Free Software Foundation, Inc.
5 5
6;; Author: FSF (see vc.el for full credits) 6;; Author: FSF (see vc.el for full credits)
@@ -52,6 +52,12 @@ BACKEND, use `vc-handled-backends'.")
52(defvar vc-header-alist ()) 52(defvar vc-header-alist ())
53(make-obsolete-variable 'vc-header-alist 'vc-BACKEND-header) 53(make-obsolete-variable 'vc-header-alist 'vc-BACKEND-header)
54 54
55(defvar vc-ignore-dir-regexp "\\`\\([\\/][\\/]\\|/net/\\|/afs/\\)\\'"
56 "Regexp matching directory names that are not under VC's control.
57The default regexp prevents fruitless and time-consuming attempts
58to determine the VC status in directories in which filenames are
59interpreted as hostnames.")
60
55(defcustom vc-handled-backends '(RCS CVS SVN SCCS Arch MCVS) 61(defcustom vc-handled-backends '(RCS CVS SVN SCCS Arch MCVS)
56 ;; Arch and MCVS come last because they are per-tree rather than per-dir. 62 ;; Arch and MCVS come last because they are per-tree rather than per-dir.
57 "*List of version control backends for which VC will be used. 63 "*List of version control backends for which VC will be used.
@@ -298,6 +304,20 @@ non-nil if FILE exists and its contents were successfully inserted."
298 (set-buffer-modified-p nil) 304 (set-buffer-modified-p nil)
299 t)) 305 t))
300 306
307(defun vc-find-root (file witness)
308 "Find the root of a checked out project.
309The function walks up the directory tree from FILE looking for WITNESS.
310If WITNESS if not found, return nil, otherwise return the root."
311 (let ((root nil))
312 (while (not (or root
313 (equal file (setq file (file-name-directory file)))
314 (null file)
315 (string-match vc-ignore-dir-regexp file)))
316 (if (file-exists-p (expand-file-name witness file))
317 (setq root file)
318 (setq file (directory-file-name file))))
319 root))
320
301;; Access functions to file properties 321;; Access functions to file properties
302;; (Properties should be _set_ using vc-file-setprop, but 322;; (Properties should be _set_ using vc-file-setprop, but
303;; _retrieved_ only through these functions, which decide 323;; _retrieved_ only through these functions, which decide
@@ -315,11 +335,13 @@ on the result of a previous call, use `vc-backend' instead. If the
315file was previously registered under a certain backend, then that 335file was previously registered under a certain backend, then that
316backend is tried first." 336backend is tried first."
317 (let (handler) 337 (let (handler)
318 (if (boundp 'file-name-handler-alist) 338 (cond
319 (setq handler (find-file-name-handler file 'vc-registered))) 339 ((string-match vc-ignore-dir-regexp (file-name-directory file)) nil)
320 (if handler 340 ((and (boundp 'file-name-handler-alist)
321 ;; handler should set vc-backend and return t if registered 341 (setq handler (find-file-name-handler file 'vc-registered)))
322 (funcall handler 'vc-registered file) 342 ;; handler should set vc-backend and return t if registered
343 (funcall handler 'vc-registered file))
344 (t
323 ;; There is no file name handler. 345 ;; There is no file name handler.
324 ;; Try vc-BACKEND-registered for each handled BACKEND. 346 ;; Try vc-BACKEND-registered for each handled BACKEND.
325 (catch 'found 347 (catch 'found
@@ -334,7 +356,7 @@ backend is tried first."
334 (cons backend vc-handled-backends)))) 356 (cons backend vc-handled-backends))))
335 ;; File is not registered. 357 ;; File is not registered.
336 (vc-file-setprop file 'vc-backend 'none) 358 (vc-file-setprop file 'vc-backend 'none)
337 nil)))) 359 nil)))))
338 360
339(defun vc-backend (file) 361(defun vc-backend (file)
340 "Return the version control type of FILE, nil if it is not registered." 362 "Return the version control type of FILE, nil if it is not registered."
@@ -869,5 +891,5 @@ Used in `find-file-not-found-functions'."
869 891
870(provide 'vc-hooks) 892(provide 'vc-hooks)
871 893
872;;; arch-tag: 2e5a6fa7-1d30-48e2-8bd0-e3d335f04f32 894;; arch-tag: 2e5a6fa7-1d30-48e2-8bd0-e3d335f04f32
873;;; vc-hooks.el ends here 895;;; vc-hooks.el ends here
diff --git a/lisp/vc-mcvs.el b/lisp/vc-mcvs.el
index 5c0bac48b3a..d2ac776170f 100644
--- a/lisp/vc-mcvs.el
+++ b/lisp/vc-mcvs.el
@@ -1,6 +1,7 @@
1;;; vc-mcvs.el --- VC backend for the Meta-CVS version-control system 1;;; vc-mcvs.el --- VC backend for the Meta-CVS version-control system
2 2
3;; Copyright (C) 1995,98,99,2000,01,02,03,2004 Free Software Foundation, Inc. 3;; Copyright (C) 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004
4;; Free Software Foundation, Inc.
4 5
5;; Author: FSF (see vc.el for full credits) 6;; Author: FSF (see vc.el for full credits)
6;; Maintainer: Stefan Monnier <monnier@gnu.org> 7;; Maintainer: Stefan Monnier <monnier@gnu.org>
@@ -114,32 +115,15 @@ This is only meaningful if you don't use the implicit checkout model
114;;; 115;;;
115 116
116;;;###autoload (defun vc-mcvs-registered (file) 117;;;###autoload (defun vc-mcvs-registered (file)
117;;;###autoload (let ((dir file)) 118;;;###autoload (if (vc-find-root file "MCVS/CVS")
118;;;###autoload (while (and (stringp dir) 119;;;###autoload (progn
119;;;###autoload (not (equal 120;;;###autoload (load "vc-mcvs")
120;;;###autoload dir (setq dir (file-name-directory dir)))) 121;;;###autoload (vc-mcvs-registered file))))
121;;;###autoload dir)
122;;;###autoload (setq dir (if (file-directory-p
123;;;###autoload (expand-file-name "MCVS/CVS" dir))
124;;;###autoload t (directory-file-name dir))))
125;;;###autoload (if (eq dir t)
126;;;###autoload (progn
127;;;###autoload (load "vc-mcvs")
128;;;###autoload (vc-mcvs-registered file)))))
129 122
130(defun vc-mcvs-root (file) 123(defun vc-mcvs-root (file)
131 "Return the root directory of a Meta-CVS project, if any." 124 "Return the root directory of a Meta-CVS project, if any."
132 (or (vc-file-getprop file 'mcvs-root) 125 (or (vc-file-getprop file 'mcvs-root)
133 (vc-file-setprop 126 (vc-file-setprop file 'mcvs-root (vc-find-root file "MCVS/CVS"))))
134 file 'mcvs-root
135 (let ((root nil))
136 (while (not (or root
137 (equal file (setq file (file-name-directory file)))
138 (null file)))
139 (if (file-directory-p (expand-file-name "MCVS/CVS" file))
140 (setq root file)
141 (setq file (directory-file-name file))))
142 root))))
143 127
144(defun vc-mcvs-read (file) 128(defun vc-mcvs-read (file)
145 (if (file-readable-p file) 129 (if (file-readable-p file)
@@ -608,5 +592,5 @@ and that it passes `vc-mcvs-global-switches' to it before FLAGS."
608 592
609(provide 'vc-mcvs) 593(provide 'vc-mcvs)
610 594
611;;; arch-tag: a39c7c1c-5247-429d-88df-dd7187d2e704 595;; arch-tag: a39c7c1c-5247-429d-88df-dd7187d2e704
612;;; vc-mcvs.el ends here 596;;; vc-mcvs.el ends here
diff --git a/lisp/windmove.el b/lisp/windmove.el
index 642f04a1d8d..986280c0bb1 100644
--- a/lisp/windmove.el
+++ b/lisp/windmove.el
@@ -324,11 +324,11 @@ from `windmove-frame-edges' will be the list (0 0 180 75)."
324 (let* ((frame (if window 324 (let* ((frame (if window
325 (window-frame window) 325 (window-frame window)
326 (selected-frame))) 326 (selected-frame)))
327 (top-left (window-inside-edges (frame-first-window frame))) 327 (top-left (window-edges (frame-first-window frame)))
328 (x-min (nth 0 top-left)) 328 (x-min (nth 0 top-left))
329 (y-min (nth 1 top-left)) 329 (y-min (nth 1 top-left))
330 (x-max (+ x-min (frame-width frame) -1)) ; 1- for last row & col 330 (x-max (1- (frame-width frame))) ; 1- for last row & col
331 (y-max (+ x-max (frame-height frame) -1))) 331 (y-max (1- (frame-height frame))))
332 (list x-min y-min x-max y-max))) 332 (list x-min y-min x-max y-max)))
333 333
334;; it turns out that constraining is always a good thing, even when 334;; it turns out that constraining is always a good thing, even when
@@ -406,7 +406,7 @@ Returns the wrapped coordinate."
406 406
407 407
408;; `windmove-coordinates-of-position' is stolen and modified from the 408;; `windmove-coordinates-of-position' is stolen and modified from the
409;; Emacs Lisp Reference Manual, section 27.2.5. It seems to work 409;; Emacs 20 Lisp Reference Manual, section 27.2.5. It seems to work
410;; okay, although I am bothered by the fact that tab-offset (the cdr 410;; okay, although I am bothered by the fact that tab-offset (the cdr
411;; of the next-to- last argument) is set to 0. On the other hand, I 411;; of the next-to- last argument) is set to 0. On the other hand, I
412;; can't find a single usage of `compute-motion' anywhere that doesn't 412;; can't find a single usage of `compute-motion' anywhere that doesn't
@@ -418,28 +418,43 @@ Returns the wrapped coordinate."
418;; the number that `window-width' gives, or continuation lines aren't 418;; the number that `window-width' gives, or continuation lines aren't
419;; counted correctly. I haven't seen anyone doing this before, 419;; counted correctly. I haven't seen anyone doing this before,
420;; though. 420;; though.
421(defun windmove-coordinates-of-position (pos &optional window) 421;;
422 "Return the coordinates of position POS in window WINDOW. 422;; Now updated for Emacs 21, based on the Emacs 21 Lisp Reference
423;; Manual, section 30.2.5. It is no longer necessary to subtract
424;; 1 for the usable width of the window.
425;; TODO: also handle minibuffer case, w/ `minibuffer-prompt-width'.
426(defun windmove-coordinates-of-position (pos)
427 "Return the coordinates of position POS in the current window.
423Return the window-based coodinates in a cons pair: (HPOS . VPOS), 428Return the window-based coodinates in a cons pair: (HPOS . VPOS),
424where HPOS and VPOS are the zero-based x and y components of the 429where HPOS and VPOS are the zero-based x and y components of the
425screen location of POS. If WINDOW is nil, return the coordinates in 430screen location of POS.
426the currently selected window.
427As an example, if point is in the top left corner of a window, then 431As an example, if point is in the top left corner of a window, then
428the return value from `windmove-coordinates-of-position' is (0 . 0) 432the return value from `windmove-coordinates-of-position' is (0 . 0)
429regardless of the where point is in the buffer and where the window 433regardless of the where point is in the buffer and where the window
430is placed in the frame." 434is placed in the frame."
431 (let* ((wind (if (null window) (selected-window) window)) 435 (let ((big-hairy-result (compute-motion
432 (big-hairy-result (compute-motion 436 (window-start)
433 (window-start) 437 '(0 . 0)
434 '(0 . 0) 438 pos
435 pos 439 nil ; (window-width window-height)
436 nil ; (window-width window-height) 440 nil ; window-width
437 nil ; window-width 441 (cons (window-hscroll)
438 (cons (window-hscroll) 442 0) ; why zero?
439 0) ; why zero? 443 (selected-window))))
440 wind))) 444 (cons (nth 1 big-hairy-result) ; hpos, not vpos as documented
441 (cons (nth 1 big-hairy-result) ; hpos, not vpos as documented 445 (nth 2 big-hairy-result)))) ; vpos, not hpos as documented
442 (nth 2 big-hairy-result)))) ; vpos, not hpos as documented 446
447(defun windmove-coordinates-of-window-position (pos &optional window)
448 "Return the coordinates of position POS in WINDOW.
449Return the window-based coodinates in a cons pair: (HPOS . VPOS),
450where HPOS and VPOS are the zero-based x and y components of the
451screen location of POS. If WINDOW is nil, return the coordinates in
452the currently selected window."
453 (if (null window)
454 (windmove-coordinates-of-position pos)
455 (save-selected-window
456 (select-window window)
457 (windmove-coordinates-of-position pos))))
443 458
444;; This calculates the reference location in the current window: the 459;; This calculates the reference location in the current window: the
445;; frame-based (x . y) of either point, the top-left, or the 460;; frame-based (x . y) of either point, the top-left, or the
@@ -467,8 +482,9 @@ supplied, if ARG is greater or smaller than zero, respectively."
467 ((= effective-arg 0) 482 ((= effective-arg 0)
468 (windmove-coord-add 483 (windmove-coord-add
469 top-left 484 top-left
470 (windmove-coordinates-of-position (window-point window) 485 (windmove-coordinates-of-window-position
471 window))))))) 486 (window-point window)
487 window)))))))
472 488
473;; This uses the reference location in the current window (calculated 489;; This uses the reference location in the current window (calculated
474;; by `windmove-reference-loc' above) to find a reference location 490;; by `windmove-reference-loc' above) to find a reference location
@@ -491,13 +507,13 @@ movement is relative to."
491 (- (nth 1 edges) 507 (- (nth 1 edges)
492 windmove-window-distance-delta))) ; (x, y0-d) 508 windmove-window-distance-delta))) ; (x, y0-d)
493 ((eq dir 'right) 509 ((eq dir 'right)
494 (cons (+ (nth 2 edges) 510 (cons (+ (1- (nth 2 edges)) ; -1 to get actual max x
495 windmove-window-distance-delta) 511 windmove-window-distance-delta)
496 (cdr refpoint))) ; (x1+d, y) 512 (cdr refpoint))) ; (x1+d-1, y)
497 ((eq dir 'down) 513 ((eq dir 'down) ; -1 to get actual max y
498 (cons (car refpoint) 514 (cons (car refpoint)
499 (+ (nth 3 edges) 515 (+ (1- (nth 3 edges))
500 windmove-window-distance-delta))) ; (x, y1+d) 516 windmove-window-distance-delta))) ; (x, y1+d-1)
501 (t (error "Invalid direction of movement: %s" dir))))) 517 (t (error "Invalid direction of movement: %s" dir)))))
502 518
503(defun windmove-find-other-window (dir &optional arg window) 519(defun windmove-find-other-window (dir &optional arg window)