[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/textmodes/bibtex.el
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/textmodes/bibtex.el |
Date: |
Mon, 29 May 2006 01:35:55 +0000 |
Index: emacs/lisp/textmodes/bibtex.el
diff -u emacs/lisp/textmodes/bibtex.el:1.119
emacs/lisp/textmodes/bibtex.el:1.120
--- emacs/lisp/textmodes/bibtex.el:1.119 Mon May 22 21:50:47 2006
+++ emacs/lisp/textmodes/bibtex.el Mon May 29 01:35:53 2006
@@ -183,6 +183,17 @@
:type '(repeat (choice :tag "Class"
(const :tag "catch-all" (catch-all))
(repeat :tag "Entry name" string))))
+(put 'bibtex-sort-entry-class 'safe-local-variable
+ (lambda (x) (let ((OK t))
+ (while (consp x)
+ (let ((y (pop x)))
+ (while (consp y)
+ (let ((z (pop y)))
+ (unless (or (stringp z) (eq z 'catch-all))
+ (setq OK nil))))
+ (unless (null y) (setq OK nil))))
+ (unless (null x) (setq OK nil))
+ OK)))
(defcustom bibtex-sort-ignore-string-entries t
"If non-nil, BibTeX @String entries are not sort-significant.
@@ -610,6 +621,8 @@
(const :tag "Capitalize" capitalize)
(const :tag "Upcase" upcase)
(function :tag "Conversion function")))
+(put 'bibtex-autokey-name-case-convert-function 'safe-local-variable
+ (lambda (x) (memq x '(upcase downcase capitalize identity))))
(defvaralias 'bibtex-autokey-name-case-convert
'bibtex-autokey-name-case-convert-function)
@@ -1188,13 +1201,7 @@
(defvar bibtex-string-empty-key nil
"If non-nil, `bibtex-parse-string' accepts empty key.")
-(defvar bibtex-sort-entry-class-alist
- (let ((i -1) alist)
- (dolist (class bibtex-sort-entry-class alist)
- (setq i (1+ i))
- (dolist (entry class)
- ;; all entry names should be downcase (for ease of comparison)
- (push (cons (if (stringp entry) (downcase entry) entry) i) alist))))
+(defvar bibtex-sort-entry-class-alist nil
"Alist mapping entry types to their sorting index.
Auto-generated from `bibtex-sort-entry-class'.
Used when `bibtex-maintain-sorted-entries' is `entry-class'.")
@@ -3188,6 +3195,17 @@
entry-name))
(list key nil entry-name))))))
+(defun bibtex-init-sort-entry-class-alist ()
+ (unless (local-variable-p 'bibtex-sort-entry-class-alist)
+ (set (make-local-variable 'bibtex-sort-entry-class-alist)
+ (let ((i -1) alist)
+ (dolist (class bibtex-sort-entry-class alist)
+ (setq i (1+ i))
+ (dolist (entry class)
+ ;; All entry names should be downcase (for ease of comparison).
+ (push (cons (if (stringp entry) (downcase entry) entry) i)
+ alist)))))))
+
(defun bibtex-lessp (index1 index2)
"Predicate for sorting BibTeX entries with indices INDEX1 and INDEX2.
Each index is a list (KEY CROSSREF-KEY ENTRY-NAME).
@@ -3225,13 +3243,14 @@
affected. If `bibtex-sort-ignore-string-entries' is non-nil, @String entries
are ignored."
(interactive)
- (bibtex-beginning-of-first-entry) ;; needed by `sort-subr'
- (sort-subr nil
- 'bibtex-skip-to-valid-entry ; NEXTREC function
- 'bibtex-end-of-entry ; ENDREC function
- 'bibtex-entry-index ; STARTKEY function
- nil ; ENDKEY function
- 'bibtex-lessp)) ; PREDICATE
+ (bibtex-beginning-of-first-entry) ; Needed by `sort-subr'
+ (bibtex-init-sort-entry-class-alist) ; Needed by `bibtex-lessp'.
+ (sort-subr nil
+ 'bibtex-skip-to-valid-entry ; NEXTREC function
+ 'bibtex-end-of-entry ; ENDREC function
+ 'bibtex-entry-index ; STARTKEY function
+ nil ; ENDKEY function
+ 'bibtex-lessp)) ; PREDICATE
(defun bibtex-find-crossref (crossref-key &optional pnt split)
"Move point to the beginning of BibTeX entry CROSSREF-KEY.
@@ -3332,6 +3351,7 @@
search to look for place for KEY. This requires that buffer is sorted,
see `bibtex-validate'.
Return t if preparation was successful or nil if entry KEY already exists."
+ (bibtex-init-sort-entry-class-alist) ; Needed by `bibtex-lessp'.
(let ((key (nth 0 index))
key-exist)
(cond ((or (null key)