Commit 7a0574f3 authored by Stefan Monnier's avatar Stefan Monnier
Browse files

(bibtex-autokey-name-case-convert-function)

(bibtex-sort-entry-class): Add safe-local-variable predicate.
(bibtex-sort-entry-class-alist): Don't set the global value.
(bibtex-init-sort-entry-class-alist): New fun.
(bibtex-sort-buffer, bibtex-prepare-new-entry): Call it to compute
bibtex-init-sort-entry-class-alist from the buffer-local value (if any)
of bibtex-init-sort-entry-class.
parent 6d3906d5
2006-05-28 Stefan Monnier <monnier@iro.umontreal.ca>
* textmodes/bibtex.el (bibtex-autokey-name-case-convert-function)
(bibtex-sort-entry-class): Add safe-local-variable predicate.
(bibtex-sort-entry-class-alist): Don't set the global value.
(bibtex-init-sort-entry-class-alist): New fun.
(bibtex-sort-buffer, bibtex-prepare-new-entry): Call it to compute
bibtex-init-sort-entry-class-alist from the buffer-local value (if any)
of bibtex-init-sort-entry-class.
2006-05-28 Richard Stallman <rms@gnu.org>
 
* subr.el (load-history-regexp): If FILE is relative, insist
......@@ -6,7 +16,7 @@
 
2006-05-29 Kim F. Storm <storm@cua.dk>
 
* emacs-lisp/bindat.el (bindat-idx, bindat-raw): Rename dynamic variables
* emacs-lisp/bindat.el (bindat-idx, bindat-raw): Rename dynamic vars
`pos' and `raw-data' for clarity, as eval forms may access these.
 
2006-05-28 Kim F. Storm <storm@cua.dk>
......
......@@ -183,6 +183,17 @@ to all entries not explicitly mentioned."
: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 @@ See `bibtex-generate-autokey' for details."
(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 @@ The CDRs of the elements are t for header keys and nil for crossref keys.")
(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 @@ of the head of the entry found. Return nil if no entry found."
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 @@ If its value is nil use plain sorting. Text outside of BibTeX entries is not
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 @@ If `bibtex-maintain-sorted-entries' is non-nil, perform a binary
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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment