From af6fb89dbb44db059c1e911cd64369ad5a5ba887 Mon Sep 17 00:00:00 2001 From: Karl Heuer Date: Thu, 11 Jul 1996 23:13:33 +0000 Subject: [PATCH] (bibtex-reference-head): Allow spaces and tabs between opening brace or paren and key. Simplify regexp. (bibtex-type-in-head, bibtex-key-in-head): Decrement. (bibtex-mode): Use new function run-with-idle-timer instead of auto-save-hook for periodically parsing keys. (bibtex-mode-syntax-table, bibtex-autokey-name-change-strings, bibtex-autokey-titleword-change-strings): Support non-escaped double-quoted characters (as with german styles). (bibtex-field-string-quoted): Disallow lines like author = "Stefan Sch"of" until BibTeX supports them. --- lisp/textmodes/bibtex.el | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el index ae9b0c42d76..0217825736c 100644 --- a/lisp/textmodes/bibtex.el +++ b/lisp/textmodes/bibtex.el @@ -95,6 +95,13 @@ duplicates) from bibtex-mode. See also bibtex-sort-ignore-string-entries. This variable is buffer local.") (make-variable-buffer-local 'bibtex-maintain-sorted-entries) +(defvar bibtex-parse-keys-timeout auto-save-timeout + "*Specifies interval for parsing buffer for keys. +The buffer is checked every bibtex-parse-keys-timeout seconds if it is +modified since last parsing and is parsed if necessary. This is needed +only if buffer is maintained sorted (bibtex-maintain-sorted-entries +non-nil).") + (defvar bibtex-entry-field-alist '( ("Article" . (((("author" "Author1 [and Author2 ...] [and others]") @@ -326,6 +333,8 @@ See the documentation of function bibtex-generate-autokey for further detail.") '(("\\\\\\\"a" "ae") ("\\\\\\\"o" "oe") ("\\\\\\\"u" "ue") ("\\\\\\\"s" "ss") ("\\\\\\\"A" "Ae") ("\\\\\\\"O" "Oe") ("\\\\\\\"U" "Ue") + ("\\\"a" "ae") ("\\\"o" "oe") ("\\\"u" "ue") ("\\\"s" "ss") + ("\\\"A" "Ae") ("\\\"O" "Oe") ("\\\"U" "Ue") ("{" "") ("}" "")) "Alist of (old-regexp new-string) pairs. Any part of name matching a old-regexp is replaced by new-string. @@ -379,6 +388,8 @@ See the documentation of function bibtex-generate-autokey for further detail.") '(("\\\\\\\"a" "ae") ("\\\\\\\"o" "oe") ("\\\\\\\"u" "ue") ("\\\\\\\"s" "ss") ("\\\\\\\"A" "Ae") ("\\\\\\\"O" "Oe") ("\\\\\\\"U" "Ue") + ("\\\"a" "ae") ("\\\"o" "oe") ("\\\"u" "ue") ("\\\"s" "ss") + ("\\\"A" "Ae") ("\\\"O" "Oe") ("\\\"U" "Ue") ("{" "") ("}" "")) "Alist of (old-regexp new-string) pairs. Any part of title word matching a old-regexp is replaced by new-string. @@ -413,8 +424,8 @@ See the documentation of function bibtex-generate-autokey for further detail.") ;; Syntax Table, Keybindings and BibTeX Entry List (defvar bibtex-mode-syntax-table (let ((st (make-syntax-table))) - ;; [alarson:19920214.1004CST] make double quote a string quote - (modify-syntax-entry ?\" "\"" st) + (modify-syntax-entry ?\" "w" st) + ;; this was formerly "\"". Does this cause any problems? (modify-syntax-entry ?$ "$$ " st) (modify-syntax-entry ?% "< " st) (modify-syntax-entry ?' "w " st) @@ -649,8 +660,11 @@ See the documentation of function bibtex-generate-autokey for further detail.") "\\(" "\\(" "[^\"\\]" "\\)" ;; every character except quote or backslash "\\|" - "\\(" "\"[A-Za-z-]" "\\)" ;; a quote followed by a letter or dash - "\\|" +;; "\\(" "\"[A-Za-z-]" "\\)" ;; a quote followed by a letter or dash +;; "\\|" +;; last two lines commented out until lines like +;; author = "Stefan Sch"of" +;; are supported by BibTeX "\\(" "\\\\.\\|\n" "\\)" ;; a backslash followed by any character "\\)*" "\"")) @@ -693,7 +707,7 @@ See the documentation of function bibtex-generate-autokey for further detail.") ;; bibtex-field-const (see above)) (defconst bibtex-reference-head - (concat "^\\( \\|\t\\)*\\(" + (concat "^[ \t]*\\(" bibtex-reference-type "\\)[ \t]*[({][ \t]*\\(" bibtex-reference-key @@ -706,11 +720,11 @@ See the documentation of function bibtex-generate-autokey for further detail.") ;; Regexp defining format of the header line of a maybe empty ;; BibTeX reference entry (without reference key). -(defconst bibtex-type-in-head 2) +(defconst bibtex-type-in-head 1) ;; The regexp subexpression number of the type part in ;; bibtex-reference-head. -(defconst bibtex-key-in-head 3) +(defconst bibtex-key-in-head 2) ;; The regexp subexpression number of the key part in ;; bibtex-reference-head. @@ -1457,8 +1471,8 @@ non-nil." (setq bibtex-completion-candidates compl)) (error "File %s not in $BIBINPUTS paths" filename))))) bibtex-string-files) - (add-hook - 'auto-save-hook + (run-with-idle-timer + bibtex-parse-keys-timeout bibtex-parse-keys-timeout (function (lambda () (if (and -- 2.39.2