diff options
| author | Karoly Lorentey | 2004-09-13 20:33:29 +0000 |
|---|---|---|
| committer | Karoly Lorentey | 2004-09-13 20:33:29 +0000 |
| commit | 267eea215b322b02bc4bce13cae61813c50f4b5f (patch) | |
| tree | 2dec815aa97a75c7d1589e72aa814bba68d4ade9 /lisp | |
| parent | 5cd432338667788c6739f43e4aa37fb53cc2a125 (diff) | |
| parent | ef3b7aae581ae555a11aa38f13e0eb55ad93a8c7 (diff) | |
| download | emacs-267eea215b322b02bc4bce13cae61813c50f4b5f.tar.gz emacs-267eea215b322b02bc4bce13cae61813c50f4b5f.zip | |
Merged in changes from CVS trunk.
Patches applied:
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-537
Update from CVS
* 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
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-543
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-544
Update from CVS
* 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/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
Update from CVS
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-26
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-244
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 91 | ||||
| -rw-r--r-- | lisp/ChangeLog.10 | 4 | ||||
| -rw-r--r-- | lisp/emacs-lisp/checkdoc.el | 5 | ||||
| -rw-r--r-- | lisp/emulation/cua-rect.el | 3 | ||||
| -rw-r--r-- | lisp/gnus/ChangeLog | 30 | ||||
| -rw-r--r-- | lisp/gnus/ChangeLog.2 | 16 | ||||
| -rw-r--r-- | lisp/gnus/gnus-registry.el | 26 | ||||
| -rw-r--r-- | lisp/gnus/gnus-sum.el | 4 | ||||
| -rw-r--r-- | lisp/gnus/nndb.el | 8 | ||||
| -rw-r--r-- | lisp/gnus/nnimap.el | 7 | ||||
| -rw-r--r-- | lisp/ido.el | 25 | ||||
| -rw-r--r-- | lisp/isearch.el | 8 | ||||
| -rw-r--r-- | lisp/kmacro.el | 3 | ||||
| -rw-r--r-- | lisp/progmodes/compile.el | 53 | ||||
| -rw-r--r-- | lisp/simple.el | 3 | ||||
| -rw-r--r-- | lisp/textmodes/bibtex.el | 748 | ||||
| -rw-r--r-- | lisp/vc-hooks.el | 38 |
17 files changed, 681 insertions, 391 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6d466b5a791..892e2c4790b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,94 @@ | |||
| 1 | 2004-09-13 Kim F. Storm <storm@cua.dk> | ||
| 2 | |||
| 3 | * isearch.el (isearch-resume-in-command-history): Rename from | ||
| 4 | isearch-resume-enabled and change default to nil. | ||
| 5 | |||
| 6 | 2004-09-12 Stefan <monnier@iro.umontreal.ca> | ||
| 7 | |||
| 8 | * vc-hooks.el (vc-ignore-dir-regexp): New var. | ||
| 9 | (vc-registered): Use it. | ||
| 10 | (vc-find-root): New fun. | ||
| 11 | |||
| 12 | * emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine): | ||
| 13 | Don't tell to use \\{...} when it's already done. | ||
| 14 | |||
| 15 | * textmodes/bibtex.el (bibtex-generate-url-list): Change format. | ||
| 16 | Provide a sample complex default. | ||
| 17 | (bibtex-url, bibtex-font-lock-url): Adapt to new format. | ||
| 18 | (bibtex-entry): Use mapc. | ||
| 19 | |||
| 20 | 2004-09-12 Kim F. Storm <storm@cua.dk> | ||
| 21 | |||
| 22 | * kmacro.el (kmacro-step-edit-prompt): Add "%s" format to message. | ||
| 23 | |||
| 24 | * emulation/cua-rect.el (cua--rectangle-operation): Let bind | ||
| 25 | inhibit-field-text-motion to t so rectangles work in comint buffers. | ||
| 26 | |||
| 27 | * simple.el (choose-completion-string): Set buffer before running | ||
| 28 | choose-completion-string-functions hook so it can be buffer-local. | ||
| 29 | |||
| 30 | 2004-09-12 Daniel Pfeiffer <occitan@esperanto.org> | ||
| 31 | |||
| 32 | * progmodes/compile.el (compilation-start): Parse command to see | ||
| 33 | if it starts with a cd, and if so perform it for the *compilation* | ||
| 34 | buffer. Change the header to reflect this. | ||
| 35 | |||
| 36 | 2004-09-11 Kim F. Storm <storm@cua.dk> | ||
| 37 | |||
| 38 | * ido.el (ido-enable-dot-prefix): Doc fix. | ||
| 39 | (ido-enable-dot-prefix): New defcustom. | ||
| 40 | (ido-set-matches1): Use it. | ||
| 41 | |||
| 42 | 2004-09-10 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 43 | |||
| 44 | * textmodes/bibtex.el (bibtex-mark-active) | ||
| 45 | (bibtex-run-with-idle-timer): Move the `if' inside the defun. | ||
| 46 | |||
| 47 | 2004-09-10 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de> | ||
| 48 | |||
| 49 | * textmodes/bibtex.el (bibtex-autokey-titleword-ignore): Regexp is | ||
| 50 | used in a case insensitive environment. | ||
| 51 | (bibtex-mode-map): Rearrange order of menus. | ||
| 52 | (bibtex-quoted-string-re): Obsolete. | ||
| 53 | (bibtex-complete-key-cleanup): Variable replaced by new function. | ||
| 54 | (bibtex-font-lock-keywords): Use backquotes. | ||
| 55 | (bibtex-font-lock-url-regexp): New internal variable. | ||
| 56 | (bibtex-name-in-field): New optional arg remove-opt-alt to remove | ||
| 57 | "OPT" and "ALT". | ||
| 58 | (bibtex-insert-current-kill, bibtex-make-field) | ||
| 59 | (bibtex-prepare-new-entry, bibtex-yank-pop, bibtex-String): Use unless. | ||
| 60 | (bibtex-parse-field-text): Simplify. | ||
| 61 | (bibtex-string=): New helper function. | ||
| 62 | (bibtex-member-of-regexp): Merge with bibtex-autokey-get-title. | ||
| 63 | (bibtex-map-entries): Use bibtex-string=. | ||
| 64 | (bibtex-search-entry): Use not. | ||
| 65 | (bibtex-enclosing-field): Fix docstring. | ||
| 66 | (bibtex-assoc-regexp): Obsolete. | ||
| 67 | (bibtex-format-entry): Use assoc-string and bibtex-string=. | ||
| 68 | (bibtex-autokey-get-names): Handle empty name field. | ||
| 69 | (bibtex-parse-strings): Use assoc-string and unless. | ||
| 70 | (bibtex-complete-string-cleanup): Expansion list is passed as an arg. | ||
| 71 | Use assoc-string. | ||
| 72 | (bibtex-pop): Simplify. | ||
| 73 | (bibtex-mode): Set font-lock-extra-managed-props. | ||
| 74 | (bibtex-entry-update): Use assoc-string. | ||
| 75 | (bibtex-parse-entry): Remove "OPT" and "ALT" from FIELD. | ||
| 76 | (bibtex-autofill-entry): Use bibtex-string=. | ||
| 77 | (bibtex-print-help-message): Simplify. | ||
| 78 | (bibtex-find-entry): New optional arg START. | ||
| 79 | (bibtex-validate): Use bibtex-string= and assoc-string. | ||
| 80 | Do not call obsolete function compilation-parse-errors. | ||
| 81 | (bibtex-remove-delimiters): Only remove delimiters if present. | ||
| 82 | (bibtex-copy-entry-as-kill): Add docstring. | ||
| 83 | (bibtex-clean-entry): Use bibtex-string=. Handle empty keys. | ||
| 84 | Detect duplicate keys if bibtex-maintain-sorted-entries is nil. | ||
| 85 | (bibtex-complete): Use bibtex-predefined-month-strings, | ||
| 86 | bibtex-string=, and new function bibtex-complete-key-cleanup. | ||
| 87 | (bibtex-generate-url-list): New variable. | ||
| 88 | (bibtex-url): New command bound to C-c C-l and mouse-2. | ||
| 89 | (bibtex-url-map): New local keymap for bibtex-url-mouse. | ||
| 90 | (bibtex-font-lock-url): New function. | ||
| 91 | |||
| 1 | 2004-09-09 Stefan Monnier <monnier@iro.umontreal.ca> | 92 | 2004-09-09 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 93 | ||
| 3 | * progmodes/grep.el (grep-mode): Remove unnecessary autoload. | 94 | * progmodes/grep.el (grep-mode): Remove unnecessary autoload. |
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 @@ | |||
| 14327 | 2002-06-01 Kim F. Storm <storm@cua.dk> | 14327 | 2002-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 @@ | |||
| 14348 | 2002-06-01 Kim F. Storm <storm@cua.dk> | 14348 | 2002-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/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/gnus/ChangeLog b/lisp/gnus/ChangeLog index 0f0f4697c47..668607af94d 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog | |||
| @@ -1,3 +1,23 @@ | |||
| 1 | 2004-09-13 Reiner Steib <Reiner.Steib@gmx.de> | ||
| 2 | |||
| 3 | * gnus-sum.el (gnus-summary-copy-article): Fixed doc string. | ||
| 4 | |||
| 5 | 2004-09-10 Miles Bader <miles@gnu.ai.mit.edu> | ||
| 6 | |||
| 7 | * nnimap.el (nnimap-open-connection): Remove extraneous end-paren. | ||
| 8 | |||
| 9 | 2004-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 | |||
| 17 | 2004-09-10 Simon Josefsson <jas@extundo.com> | ||
| 18 | |||
| 19 | * nndb.el (require): Remove tcp and duplicate cl. | ||
| 20 | |||
| 1 | 2004-09-08 Reiner Steib <Reiner.Steib@gmx.de> | 21 | 2004-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: | 411 | See 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: | 18916 | 2000-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 | |||
| 18920 | See 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 77d5037b32d..02757fff4dd 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. |
| 9060 | If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to. | 9060 | If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to. |
| 9061 | When called interactively, if TO-NEWSGROUP is nil, use the value of | 9061 | When called interactively, if TO-NEWSGROUP is nil, use the value of |
| 9062 | the variable `gnus-move-split-methods' for finding a default target | 9062 | the variable `gnus-move-split-methods' for finding a default target |
| 9063 | newsgroup. | 9063 | newsgroup. |
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/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. |
| 486 | arbitrary substring (default). If non-nil `ido' will only match if the inserted | 486 | This behavior is like the standard emacs-completion. |
| 487 | text is a prefix \(this behavior is like the standard unix- or | 487 | Nil means to match if the entered text is an arbitrary substring. |
| 488 | emacs-completion works). | ||
| 489 | Value can be toggled within `ido' using `ido-toggle-prefix'." | 488 | Value 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. | ||
| 494 | I.e. hidden files and buffers will match only if you type a dot | ||
| 495 | as 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. |
| 495 | This means that \\[ido-complete] must always be followed by \\[ido-exit-minibuffer] | 501 | This 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 2398d56ab5f..117d1bfdc13 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. |
| 151 | This allows you to resume earlier isearch sessions through the | ||
| 152 | command history." | ||
| 151 | :type 'boolean | 153 | :type 'boolean |
| 152 | :group 'isearch) | 154 | :group 'isearch) |
| 153 | 155 | ||
| @@ -651,7 +653,7 @@ is treated as a regexp. See \\[isearch-forward] for more info." | |||
| 651 | (setq disable-point-adjustment t)) | 653 | (setq disable-point-adjustment t)) |
| 652 | 654 | ||
| 653 | (defun isearch-done (&optional nopush edit) | 655 | (defun isearch-done (&optional nopush edit) |
| 654 | (if isearch-resume-enabled | 656 | (if isearch-resume-in-command-history |
| 655 | (let ((command `(isearch-resume ,isearch-string ,isearch-regexp | 657 | (let ((command `(isearch-resume ,isearch-string ,isearch-regexp |
| 656 | ,isearch-word ,isearch-forward | 658 | ,isearch-word ,isearch-forward |
| 657 | ,isearch-message | 659 | ,isearch-message |
diff --git a/lisp/kmacro.el b/lisp/kmacro.el index 9e3271d01cc..5aefe46625d 100644 --- a/lisp/kmacro.el +++ b/lisp/kmacro.el | |||
| @@ -928,7 +928,8 @@ following additional answers: `insert', `insert-1', `replace', `replace-1', | |||
| 928 | (curmsg (current-message))) | 928 | (curmsg (current-message))) |
| 929 | 929 | ||
| 930 | ;; TODO: Scroll macro if max-mini-window-height is too small. | 930 | ;; TODO: Scroll macro if max-mini-window-height is too small. |
| 931 | (message (concat | 931 | (message "%s" |
| 932 | (concat | ||
| 932 | (format "Macro: %s%s%s%s%s\n" | 933 | (format "Macro: %s%s%s%s%s\n" |
| 933 | (format-kbd-macro kmacro-step-edit-new-macro 1) | 934 | (format-kbd-macro kmacro-step-edit-new-macro 1) |
| 934 | (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/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). |
| 852 | If COMMAND starts with a cd command, that becomes the `default-directory'. | ||
| 852 | The rest of the arguments are optional; for them, nil means use the default. | 853 | The rest of the arguments are optional; for them, nil means use the default. |
| 853 | 854 | ||
| 854 | MODE is the major mode to set in the compilation buffer. Mode | 855 | MODE is the major mode to set in the compilation buffer. Mode |
| @@ -861,26 +862,29 @@ global value of `compilation-highlight-regexp'. | |||
| 861 | 862 | ||
| 862 | Returns the compilation buffer created." | 863 | Returns 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/simple.el b/lisp/simple.el index 14fa1931e40..588191241c5 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -4301,11 +4301,12 @@ to decide what to delete." | |||
| 4301 | (not (equal buffer | 4301 | (not (equal buffer |
| 4302 | (window-buffer (active-minibuffer-window)))))) | 4302 | (window-buffer (active-minibuffer-window)))))) |
| 4303 | (error "Minibuffer is not active for completion") | 4303 | (error "Minibuffer is not active for completion") |
| 4304 | ;; Set buffer so buffer-local choose-completion-string-functions works. | ||
| 4305 | (set-buffer buffer) | ||
| 4304 | (unless (run-hook-with-args-until-success | 4306 | (unless (run-hook-with-args-until-success |
| 4305 | 'choose-completion-string-functions | 4307 | 'choose-completion-string-functions |
| 4306 | choice buffer mini-p base-size) | 4308 | choice buffer mini-p base-size) |
| 4307 | ;; Insert the completion into the buffer where it was requested. | 4309 | ;; Insert the completion into the buffer where it was requested. |
| 4308 | (set-buffer buffer) | ||
| 4309 | (if base-size | 4310 | (if base-size |
| 4310 | (delete-region (+ base-size (if mini-p | 4311 | (delete-region (+ base-size (if mini-p |
| 4311 | (minibuffer-prompt-end) | 4312 | (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." | |||
| 154 | Allowed non-nil values are: | 154 | Allowed non-nil values are: |
| 155 | plain All entries are sorted alphabetically. | 155 | plain All entries are sorted alphabetically. |
| 156 | crossref All entries are sorted alphabetically unless an entry has a | 156 | crossref 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. |
| 159 | entry-class The entries are divided into classes according to their | 159 | entry-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. |
| 162 | See also `bibtex-sort-ignore-string-entries'." | 162 | See 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. |
| 174 | If value of `bibtex-maintain-sorted-entries' is `entry-class' | 174 | If value of `bibtex-maintain-sorted-entries' is `entry-class' |
| 175 | entries are ordered according to the classes they belong to. Each | 175 | entries are ordered according to the classes they belong to. Each |
| 176 | class contains a list of entry names. An entry `catch-all' applies | 176 | class contains a list of entry names. An entry `catch-all' applies |
| 177 | to all entries not explicitely mentioned.") | 177 | to 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. |
| 645 | Each item of the list is a regexp. If a word of the title matchs a | 645 | Each item of the list is a regexp. If a word of the title matchs a |
| 646 | regexp from that list, it is not included in the title part of the key. | 646 | regexp 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. | ||
| 776 | These schemes are used by `bibtex-url'. | ||
| 777 | |||
| 778 | Each scheme is of the form ((FIELD . REGEXP) STEP...). | ||
| 779 | |||
| 780 | FIELD is a field name as returned by `bibtex-parse-entry'. | ||
| 781 | REGEXP is matched against the text of FIELD. If the match succeed, then | ||
| 782 | this scheme will be used. If no STEPS are specified the matched text is used | ||
| 783 | as the URL, otherwise the URL is built by concatenating the STEPS. | ||
| 784 | |||
| 785 | A STEP can be a string or a list (FIELD REGEXP REPLACE) in which case | ||
| 786 | the text of FIELD is matched against REGEXP, and is replaced with REPLACE. | ||
| 787 | REPLACE can be a string, or a number (which selects the corresponding submatch) | ||
| 788 | or a function called with the field's text as argument and with the | ||
| 789 | `match-data' properly set. | ||
| 790 | |||
| 791 | Case 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.") |
| 958 | was 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'. |
| 1077 | function `bibtex-parse-field-name'.") | 1117 | Passed 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'.") | 1127 | Auto-generated from `bibtex-sort-entry-class'. |
| 1128 | Used 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) | 1154 | ARG 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'. |
| 1145 | If the field name is found, return a triple consisting of the position of the | 1182 | If the field name is found, return a triple consisting of the position of the |
| 1146 | very first character of the match, the actual starting position of the name | 1183 | very first character of the match, the actual starting position of the name |
| 1147 | part and end position of the match. Move point to end of field name. | 1184 | part and end position of the match. Move point to end of field name. |
| 1148 | If `bibtex-autoadd-commas' is non-nil add missing comma at end of preceeding | 1185 | If `bibtex-autoadd-commas' is non-nil add missing comma at end of preceeding |
| 1149 | BibTeX field as necessary." | 1186 | BibTeX 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." | |||
| 1206 | The text part is either a string, or an empty string, or a constant followed | 1243 | The text part is either a string, or an empty string, or a constant followed |
| 1207 | by one or more <# (string|constant)> pairs. If a syntactically correct text | 1244 | by one or more <# (string|constant)> pairs. If a syntactically correct text |
| 1208 | is found, a pair containing the start and end position of the text is | 1245 | is found, a pair containing the start and end position of the text is |
| 1209 | returned, nil otherwise. Move point to end of field text." | 1246 | returned, 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. |
| 1235 | If a syntactically correct field is found, a pair containing the boundaries of | 1272 | If a syntactically correct field is found, a pair containing the boundaries of |
| 1236 | the name and text parts of the field is returned. The search is limited by | 1273 | the name and text parts of the field is returned. The search is limited by |
| 1237 | optional arg BOUND. If BOUND is t the search is limited by the end of the current | 1274 | optional arg BOUND. If BOUND is t the search is limited by the end of the |
| 1238 | entry. Do not move point." | 1275 | current 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. |
| 1262 | If a syntactically correct field is found, a pair containing the boundaries of | 1299 | If a syntactically correct field is found, a pair containing the boundaries of |
| 1263 | the name and text parts of the field is returned. The search is limited by | 1300 | the name and text parts of the field is returned. The search is limited by |
| 1264 | optional arg BOUND. If BOUND is t the search is limited by the beginning of the | 1301 | optional arg BOUND. If BOUND is t the search is limited by the beginning of the |
| 1265 | current entry. Do not move point." | 1302 | current 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)) | 1336 | If 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. |
| 1315 | If optional arg FOLLOW-CROSSREF is non-nil, follow crossref." | 1357 | If 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. |
| 1352 | If the string postfix is found, return a triple consisting of the position of | 1394 | If the string postfix is found, return a triple consisting of the position of |
| 1353 | the actual starting and ending position of the text and the very last | 1395 | the actual starting and ending position of the text and the very last |
| 1354 | character of the string entry. Move point past BibTeX string entry." | 1396 | character 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. |
| 1375 | If a syntactically correct entry is found, a pair containing the boundaries of | 1417 | If a syntactically correct entry is found, a pair containing the boundaries of |
| 1376 | the reference key and text parts of the string is returned. Do not move point." | 1418 | the 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. |
| 1391 | If a syntactically correct entry is found, a pair containing the boundaries of | 1433 | If a syntactically correct entry is found, a pair containing the boundaries of |
| 1392 | the reference key and text parts of the field is returned. Do not move point." | 1434 | the 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. | ||
| 1453 | The 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. |
| 1462 | next valid one. With optional argument BACKWARD non-nil, move backward to | 1499 | Do not move if we are already at beginning of a valid BibTeX entry. |
| 1463 | beginning of previous valid one. A valid entry is a syntactical correct one | 1500 | With optional argument BACKWARD non-nil, move backward to |
| 1501 | beginning of previous valid one. A valid entry is a syntactical correct one | ||
| 1464 | with type contained in `bibtex-entry-field-alist' or, if | 1502 | with 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 |
| 1466 | entry. Return buffer position of beginning and ending of entry if a valid | 1504 | entry. Return buffer position of beginning and ending of entry if a valid |
| 1467 | entry is found, nil otherwise." | 1505 | entry 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. |
| 1491 | Do this to the end of the file. FUN is called with three arguments, the key of | 1529 | Do this to the end of the file. FUN is called with three arguments, the key of |
| 1492 | the entry and the buffer positions (marker) of beginning and end of entry. | 1530 | the entry and the buffer positions (marker) of beginning and end of entry. |
| 1493 | Point is inside the entry. If `bibtex-sort-ignore-string-entries' is non-nil, | 1531 | Point is inside the entry. If `bibtex-sort-ignore-string-entries' is non-nil, |
| 1494 | FUN will not be called for @String entries." | 1532 | FUN 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). |
| 1559 | BOUND and NOERROR are exactly as in `re-search-forward'. If BACKWARD | 1597 | BOUND and NOERROR are exactly as in `re-search-forward'. If BACKWARD |
| 1560 | is non-nil, search is done in reverse direction. Point is moved past the | 1598 | is non-nil, search is done in reverse direction. Point is moved past the |
| 1561 | closing delimiter (at the beginning of entry if BACKWARD is non-nil). | 1599 | closing delimiter (at the beginning of entry if BACKWARD is non-nil). |
| 1562 | Return a cons pair with buffer positions of beginning and end of entry. | 1600 | Return a cons pair with buffer positions of beginning and end of entry. |
| 1563 | After call to this function MATCH-BEGINNING and MATCH-END functions | 1601 | After 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. |
| 1688 | Use `match-beginning' and `match-end' to parse the field. If NOERR is non-nil, | 1726 | Use `match-beginning' and `match-end' to parse the field. If NOERR is non-nil, |
| 1689 | no error is signalled. In this case, bounds are returned on success, | 1727 | no error is signalled. In this case, bounds are returned on success, |
| 1690 | nil otherwise." | 1728 | nil 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. |
| 1701 | Beginning (but not end) of entry is given by (`match-beginning' 0)." | 1739 | Beginning (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. | ||
| 1746 | The value is actually the element of ALIST matched by REGEXP. | ||
| 1747 | Case 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'. |
| 1755 | Formats current entry according to variable `bibtex-entry-format'." | 1783 | Formats 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. |
| 1992 | If LEN is positive the abbreviation is terminated only after a consonant | 2016 | If LEN is positive the abbreviation is terminated only after a consonant |
| 1993 | or at the word end. If LEN is negative the abbreviation is strictly | 2017 | or at the word end. If LEN is negative the abbreviation is strictly |
| 1994 | enforced using abs (LEN) characters. If LEN is not a number, STRING | 2018 | enforced using abs (LEN) characters. If LEN is not a number, STRING |
| 1995 | is returned unchanged." | 2019 | is 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. |
| 2011 | Optional arg CHANGE-LIST is a list of substitution patterns that is | 2035 | Optional arg CHANGE-LIST is a list of substitution patterns that is |
| 2012 | applied to the content of FIELD. It is an alist with pairs | 2036 | applied 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. |
| 2024 | Do some modifications based on `bibtex-autokey-name-change-strings' | 2048 | Do some modifications based on `bibtex-autokey-name-change-strings' |
| 2025 | and return results as a list." | 2049 | and 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. |
| 2098 | The rules are defined in `bibtex-autokey-titleword-abbrevs' | 2127 | The rules are defined in `bibtex-autokey-titleword-abbrevs' |
| 2099 | and `bibtex-autokey-titleword-length'." | 2128 | and `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. |
| 2176 | 16. If the value of `bibtex-autokey-before-presentation-function' | 2205 | 16. 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. |
| 2181 | 17. If the value of `bibtex-autokey-edit-before-use' is non-nil, | 2210 | 17. 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: | |||
| 2230 | The buffer might possibly be restricted. | 2259 | The buffer might possibly be restricted. |
| 2231 | Find both entry keys and crossref entries. | 2260 | Find both entry keys and crossref entries. |
| 2232 | If ADD is non-nil add the new keys to `bibtex-reference-keys' instead of | 2261 | If ADD is non-nil add the new keys to `bibtex-reference-keys' instead of |
| 2233 | simply resetting it. If ADD is an alist of keys, also add ADD to | 2262 | simply 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 |
| 2235 | input. If VERBOSE is non-nil gives messages about progress. | 2264 | input. If VERBOSE is non-nil gives messages about progress. |
| 2236 | Return alist of keys if parsing was completed, `aborted' otherwise." | 2265 | Return 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. |
| 2297 | The buffer might possibly be restricted. | 2326 | The buffer might possibly be restricted. |
| 2298 | If ADD is non-nil add the new strings to `bibtex-strings' instead of | 2327 | If ADD is non-nil add the new strings to `bibtex-strings' instead of |
| 2299 | simply resetting it. If ADD is an alist of strings, also add ADD to | 2328 | simply 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. |
| 2301 | Return alist of strings if parsing was completed, `aborted' otherwise." | 2330 | Return 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. |
| 2390 | Called by `bibtex-run-with-idle-timer'. Whenever Emacs has been idle | ||
| 2361 | for `bibtex-parse-keys-timeout' seconds, all BibTeX buffers (starting | 2391 | for `bibtex-parse-keys-timeout' seconds, all BibTeX buffers (starting |
| 2362 | with the current) are parsed." | 2392 | with 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. |
| 2385 | string defined in list COMPLETIONS. If point is not after the part | 2415 | COMPLETIONS should be a list of strings. If point is not after the part |
| 2386 | of a word, all strings are listed. Return completion." | 2416 | of 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. |
| 2414 | Remove enclosing field delimiters for string STR. Display message with | 2444 | Remove enclosing field delimiters for string STR. Display message with |
| 2415 | expansion of STR." | 2445 | expansion 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. |
| 2517 | Generic 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." | |||
| 2523 | General information on working with BibTeX mode: | 2577 | General information on working with BibTeX mode: |
| 2524 | 2578 | ||
| 2525 | You should use commands such as \\[bibtex-Book] to get a template for a | 2579 | You should use commands such as \\[bibtex-Book] to get a template for a |
| 2526 | specific entry. You should then fill in all desired fields using | 2580 | specific 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 |
| 2528 | in all desired fields in the entry, you should clean the new entry | 2582 | in all desired fields in the entry, you should clean the new entry |
| 2529 | with the command \\[bibtex-clean-entry]. | 2583 | with the command \\[bibtex-clean-entry]. |
| 2530 | 2584 | ||
| 2531 | Some features of BibTeX mode are available only by setting the variable | 2585 | Some 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 |
| 2533 | work only with buffers containing valid (syntactical correct) entries | 2587 | work only with buffers containing valid (syntactical correct) entries |
| 2534 | and with entries being sorted. This is usually the case, if you have | 2588 | and with entries being sorted. This is usually the case, if you have |
| 2535 | created a buffer completely with BibTeX mode and finished every new | 2589 | created a buffer completely with BibTeX mode and finished every new |
| 2536 | entry with \\[bibtex-clean-entry]. | 2590 | entry 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. |
| 2685 | After insertion it calls the functions in `bibtex-add-entry-hook'." | 2740 | After 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. |
| 2738 | The alist elements have the form (FIELD . TEXT), where FIELD can also be | 2790 | The alist elements have the form (FIELD . TEXT), where FIELD can also be |
| 2739 | the special strings \"=type=\" and \"=key=\". For the FIELD \"=key=\" | 2791 | the special strings \"=type=\" and \"=key=\". For the FIELD \"=key=\" |
| 2740 | TEXT may be nil. Move point to the end of the last field." | 2792 | TEXT may be nil. Remove \"OPT\" and \"ALT\" from FIELD. |
| 2793 | Move 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. |
| 2844 | FIELD is either a string or a list of the form | 2888 | FIELD 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'. |
| 2891 | If 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). |
| 2887 | If inside an entry, move to the beginning of it, otherwise move to the | 2932 | If inside an entry, move to the beginning of it, otherwise move to the |
| 2888 | beginning of the previous entry. If point is ahead of all BibTeX entries | 2933 | beginning of the previous entry. If point is ahead of all BibTeX entries |
| 2889 | move point to the beginning of buffer. Return the new location of point." | 2934 | move 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). |
| 2899 | If inside an entry, move to the end of it, otherwise move to the end | 2944 | If inside an entry, move to the end of it, otherwise move to the end |
| 2900 | of the previous entry. Do not move if ahead of first entry. | 2945 | of the previous entry. Do not move if ahead of first entry. |
| 2901 | Return the new location of point." | 2946 | Return 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. |
| 3001 | The index is a list (KEY CROSSREF-KEY ENTRY-NAME) that is used for sorting | 3046 | The index is a list (KEY CROSSREF-KEY ENTRY-NAME) that is used for sorting |
| 3002 | the entries of the BibTeX buffer. Return nil if no entry found." | 3047 | the 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. |
| 3051 | The predicate for sorting is defined via `bibtex-maintain-sorted-entries'. | 3096 | The predicate for sorting is defined via `bibtex-maintain-sorted-entries'. |
| 3052 | If its value is nil use plain sorting. Text outside of BibTeX entries is not | 3097 | If its value is nil use plain sorting. Text outside of BibTeX entries is not |
| 3053 | affected. If `bibtex-sort-ignore-string-entries' is non-nil, @String entries | 3098 | affected. If `bibtex-sort-ignore-string-entries' is non-nil, @String entries |
| 3054 | will be ignored." | 3099 | will 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. |
| 3089 | Return position of entry if KEY is found or nil if not found." | 3134 | Return position of entry if KEY is found or nil if not found. |
| 3090 | (interactive (list (bibtex-read-key "Find key: "))) | 3135 | Optional arg START is buffer position where the search starts. |
| 3136 | If it is nil, start search at beginning of buffer. | ||
| 3137 | With 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." | |||
| 3108 | INDEX is a list (KEY CROSSREF-KEY ENTRY-NAME). | 3157 | INDEX is a list (KEY CROSSREF-KEY ENTRY-NAME). |
| 3109 | Move point where the entry KEY should be placed. | 3158 | Move point where the entry KEY should be placed. |
| 3110 | If `bibtex-maintain-sorted-entries' is non-nil, perform a binary | 3159 | If `bibtex-maintain-sorted-entries' is non-nil, perform a binary |
| 3111 | search to look for place for KEY. This will fail if buffer is not in | 3160 | search to look for place for KEY. This will fail if buffer is not in |
| 3112 | sorted order, see \\[bibtex-validate].) | 3161 | sorted order, see \\[bibtex-validate].) |
| 3113 | Return t if preparation was successful or nil if entry KEY already exists." | 3162 | Return 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. | |||
| 3482 | The sequence of kills wraps around, so that after the oldest one | 3526 | The sequence of kills wraps around, so that after the oldest one |
| 3483 | comes the newest one." | 3527 | comes 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)." | |||
| 3519 | Check that no required fields are empty and formats entry dependent | 3563 | Check that no required fields are empty and formats entry dependent |
| 3520 | on the value of `bibtex-entry-format'. | 3564 | on the value of `bibtex-entry-format'. |
| 3521 | If the reference key of the entry is empty or a prefix argument is given, | 3565 | If the reference key of the entry is empty or a prefix argument is given, |
| 3522 | calculate a new reference key. (Note: this will only work if fields in entry | 3566 | calculate a new reference key. (Note: this will only work if fields in entry |
| 3523 | begin on separate lines prior to calling `bibtex-clean-entry' or if | 3567 | begin 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'.) |
| 3525 | Don't call `bibtex-clean-entry' on @Preamble entries. | 3569 | Don'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. |
| 3754 | If point is inside key or crossref field perform key completion based on | 3801 | If 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 |
| 3756 | completion based on `bibtex-strings'. An error is signaled if point | 3803 | based on `bibtex-predefined-month-strings'. Inside any other field |
| 3757 | is outside key or BibTeX field." | 3804 | perform string completion based on `bibtex-strings'. An error is |
| 3805 | signaled 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. | ||
| 3965 | The 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/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. | ||
| 57 | The default regexp prevents fruitless and time-consuming attempts | ||
| 58 | to determine the VC status in directories in which filenames are | ||
| 59 | interpreted 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. | ||
| 309 | The function walks up the directory tree from FILE looking for WITNESS. | ||
| 310 | If 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 | |||
| 315 | file was previously registered under a certain backend, then that | 335 | file was previously registered under a certain backend, then that |
| 316 | backend is tried first." | 336 | backend 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 |