diff options
Diffstat (limited to 'lisp/textmodes/bibtex.el')
-rw-r--r-- | lisp/textmodes/bibtex.el | 126 |
1 files changed, 83 insertions, 43 deletions
diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el index e4df28d03de..8135d40d261 100644 --- a/lisp/textmodes/bibtex.el +++ b/lisp/textmodes/bibtex.el @@ -316,8 +316,6 @@ If parsing fails, try to set this variable to nil." (option (choice :tag "Alternative" :value nil (const nil) integer))))))) -(define-obsolete-variable-alias 'bibtex-entry-field-alist - 'bibtex-BibTeX-entry-alist "24.1") (defcustom bibtex-BibTeX-entry-alist '(("Article" "Article in Journal" (("author") @@ -764,6 +762,20 @@ for a new entry." ("eprint") ("eprintclass" nil nil 4) ("primaryclass" nil nil -4) ("eprinttype" nil nil 5) ("archiveprefix" nil nil -5) ("url") ("urldate"))) + ("Conference" "Article in Conference Proceedings" ; same as InProceedings + (("author") + ("title" "Title of the article in proceedings (BibTeX converts it to lowercase)")) + (("booktitle" "Name of the conference proceedings") + ("year")) + (("editor") + ("volume" "Volume of the conference proceedings in the series") + ("number" "Number of the conference proceedings in a small series (overwritten by volume)") + ("series" "Series in which the conference proceedings appeared") + ("pages" "Pages in the conference proceedings") + ("month") ("address") + ("organization" "Sponsoring organization of the conference") + ("publisher" "Publishing company, its location") + ("note"))) ("Reference" "Single-Volume Work of Reference" ; same as @collection (("editor") ("title") ("date" nil nil 1) ("year" nil nil -1)) nil @@ -839,6 +851,33 @@ for a new entry." ("eprint") ("eprintclass" nil nil 4) ("primaryclass" nil nil -4) ("eprinttype" nil nil 5) ("archiveprefix" nil nil -5) ("url") ("urldate"))) + ("PhdThesis" "PhD Thesis" + (("author") + ("title" "Title of the PhD thesis") + ("school" "School where the PhD thesis was written") + ("year")) + nil + (("type" "Type of the PhD thesis") + ("address" "Address of the school (if not part of field \"school\") or country") + ("month") ("note"))) + ("MastersThesis" "Master's Thesis" + (("author") + ("title" "Title of the master's thesis (BibTeX converts it to lowercase)") + ("school" "School where the master's thesis was written") + ("year")) + nil + (("type" "Type of the master's thesis (if other than \"Master's thesis\")") + ("address" "Address of the school (if not part of field \"school\") or country") + ("month") ("note"))) + ("TechReport" "Technical Report" + (("author") + ("title" "Title of the technical report (BibTeX converts it to lowercase)") + ("institution" "Sponsoring institution of the report") + ("year")) + nil + (("type" "Type of the report (if other than \"technical report\")") + ("number" "Number of the technical report") + ("address") ("month") ("note"))) ("Unpublished" "Unpublished" (("author") ("title") ("date" nil nil 1) ("year" nil nil -1)) nil @@ -1193,8 +1232,8 @@ See `bibtex-generate-autokey' for details." :type '(repeat (cons (regexp :tag "Old") (string :tag "New")))) -(defvaralias 'bibtex-autokey-name-case-convert - 'bibtex-autokey-name-case-convert-function) +(define-obsolete-variable-alias 'bibtex-autokey-name-case-convert + 'bibtex-autokey-name-case-convert-function "29.1") (defcustom bibtex-autokey-name-case-convert-function #'downcase "Function called for each name to perform case conversion. @@ -1268,8 +1307,8 @@ Case is significant. See `bibtex-generate-autokey' for details." :group 'bibtex-autokey :type '(repeat regexp)) -(defvaralias 'bibtex-autokey-titleword-case-convert - 'bibtex-autokey-titleword-case-convert-function) +(define-obsolete-variable-alias 'bibtex-autokey-titleword-case-convert + 'bibtex-autokey-titleword-case-convert-function "29.1") (defcustom bibtex-autokey-titleword-case-convert-function #'downcase "Function called for each titleword to perform case conversion. @@ -2176,6 +2215,7 @@ Point must be at beginning of preamble. Do not move point." (defsubst bibtex-string= (str1 str2) "Return t if STR1 and STR2 are equal, ignoring case." + (declare (obsolete string-equal-ignore-case "29.1")) (eq t (compare-strings str1 0 nil str2 0 nil t))) (defun bibtex-delete-whitespace () @@ -2257,11 +2297,17 @@ is non-nil, FUN is not called for @String entries." (set-marker-insertion-type end-marker t) (save-excursion (goto-char (point-min)) - (while (setq found (bibtex-skip-to-valid-entry)) - (set-marker end-marker (cdr found)) - (looking-at bibtex-any-entry-maybe-empty-head) - (funcall fun (bibtex-key-in-head "") (car found) end-marker) - (goto-char end-marker))))) + (let ((prev nil)) + (while (setq found (bibtex-skip-to-valid-entry)) + ;; If we have invalid entries, ensure that we have forward + ;; progress so that we don't infloop. + (if (equal (point) prev) + (forward-line 1) + (setq prev (point)) + (set-marker end-marker (cdr found)) + (looking-at bibtex-any-entry-maybe-empty-head) + (funcall fun (bibtex-key-in-head "") (car found) end-marker) + (goto-char end-marker))))))) (defun bibtex-progress-message (&optional flag interval) "Echo a message about progress of current buffer. @@ -2612,7 +2658,7 @@ Formats current entry according to variable `bibtex-entry-format'." ;; update page dashes (if (and (memq 'page-dashes format) - (bibtex-string= field-name "pages") + (string-equal-ignore-case field-name "pages") (progn (goto-char beg-text) (looking-at "\\([\"{][0-9]+\\)[ \t\n]*--?[ \t\n]*\\([0-9]+[\"}]\\)"))) @@ -2665,7 +2711,7 @@ Formats current entry according to variable `bibtex-entry-format'." ;; use book title of crossref'd entry (if (and (memq 'inherit-booktitle format) empty-field - (bibtex-string= field-name "booktitle") + (string-equal-ignore-case field-name "booktitle") crossref-key) (let ((title (save-excursion (save-restriction @@ -3458,7 +3504,7 @@ If NO-BUTTON is non-nil do not generate buttons." (let ((lst bibtex-generate-url-list) url) (while (and (not found) (setq url (car (pop lst)))) (goto-char start) - (setq found (and (bibtex-string= name (car url)) + (setq found (and (string-equal-ignore-case name (car url)) (re-search-forward (cdr url) end t)))))) (unless found (goto-char end))) (if (and found (not no-button)) @@ -3614,7 +3660,11 @@ if that value is non-nil. ?\s))))) (if (and buffer-file-name enable-local-variables) (add-hook 'hack-local-variables-hook fun nil t) - (funcall fun)))) + (funcall fun))) + ;; We may be using the mode programmatically to extract data, and we + ;; then need this to be set up first so that sexp-based movement + ;; commands don't bug out. + (font-lock-set-defaults)) (defun bibtex-entry-alist (dialect) "Return entry-alist for DIALECT." @@ -3626,14 +3676,6 @@ if that value is non-nil. (if (not (consp (nth 1 (car entry-alist)))) ;; new format entry-alist - ;; Convert old format of `bibtex-entry-field-alist' - (unless (get var 'entry-list-format) - (put var 'entry-list-format "pre-24") - (message "Old format of `%s' (pre GNU Emacs 24). -Please convert to the new format." - (if (eq (indirect-variable 'bibtex-entry-field-alist) var) - 'bibtex-entry-field-alist var)) - (sit-for 3)) (let (lst) (dolist (entry entry-alist) (let ((fl (nth 1 entry)) req xref opt) @@ -3913,7 +3955,7 @@ entry (for example, the year parts of the keys)." (goto-char (1- (match-beginning 0))) (bibtex-beginning-of-entry) (if (and (looking-at bibtex-entry-head) - (bibtex-string= type (bibtex-type-in-head)) + (string-equal-ignore-case type (bibtex-type-in-head)) ;; In case we found ourselves :-( (not (equal key (setq tmp (bibtex-key-in-head))))) (setq other-key tmp @@ -3922,7 +3964,7 @@ entry (for example, the year parts of the keys)." (bibtex-end-of-entry) (bibtex-skip-to-valid-entry) (if (and (looking-at bibtex-entry-head) - (bibtex-string= type (bibtex-type-in-head)) + (string-equal-ignore-case type (bibtex-type-in-head)) ;; In case we found ourselves :-( (not (equal key (setq tmp (bibtex-key-in-head)))) (or (not other-key) @@ -3963,9 +4005,9 @@ interactive calls." (interactive (list nil t)) (unless field (setq field (car (bibtex-find-text-internal nil nil comma)))) (if (string-search "@" field) - (cond ((bibtex-string= field "@string") + (cond ((string-equal-ignore-case field "@string") (message "String definition")) - ((bibtex-string= field "@preamble") + ((string-equal-ignore-case field "@preamble") (message "Preamble definition")) (t (message "Entry key"))) (let* ((case-fold-search t) @@ -4101,11 +4143,11 @@ Optional arg POS is the position of the BibTeX entry to use." (goto-char pnt))))) (defun bibtex-mark-entry () - "Put mark at beginning, point at end of current BibTeX entry. + "Put mark at end, point at beginning of current BibTeX entry. Activate mark in Transient Mark mode." (interactive) - (push-mark (bibtex-beginning-of-entry) t t) - (bibtex-end-of-entry)) + (push-mark (bibtex-end-of-entry) t t) + (bibtex-beginning-of-entry)) (defun bibtex-count-entries (&optional count-string-entries) "Count number of entries in current buffer or region. @@ -4317,8 +4359,6 @@ for a crossref key, t otherwise." (eqb (goto-char pos)) (t (set-buffer buffer) (goto-char pos))) pos)) -;; backward compatibility -(defalias 'bibtex-find-crossref 'bibtex-search-crossref) (defun bibtex-dist (pos beg end) "Return distance between POS and region delimited by BEG and END." @@ -4381,8 +4421,6 @@ A prefix arg negates the value of `bibtex-search-entry-globally'." (if display (bibtex-reposition-window))) (display (message "Key `%s' not found" key))) pnt))) -;; backward compatibility -(defalias 'bibtex-find-entry 'bibtex-search-entry) (defun bibtex-prepare-new-entry (index) "Prepare a new BibTeX entry with index INDEX. @@ -4551,7 +4589,7 @@ Return t if test was successful, nil otherwise." bounds field idx) (while (setq bounds (bibtex-parse-field)) (let ((field-name (bibtex-name-in-field bounds))) - (if (and (bibtex-string= field-name "month") + (if (and (string-equal-ignore-case field-name "month") ;; Check only abbreviated month fields. (let ((month (bibtex-text-in-field-bounds bounds))) (not (or (string-match "\\`[\"{].+[\"}]\\'" month) @@ -4632,7 +4670,7 @@ Return t if test was successful, nil otherwise." (while (re-search-forward bibtex-entry-head nil t) (setq entry-type (bibtex-type-in-head) key (bibtex-key-in-head)) - (if (or (and strings (bibtex-string= entry-type "string")) + (if (or (and strings (string-equal-ignore-case entry-type "string")) (assoc-string entry-type bibtex-entry-alist t)) (if (member key key-list) (push (format-message @@ -4996,7 +5034,7 @@ on the value of `bibtex-entry-format'. If the reference key of the entry is empty or a prefix argument is given, calculate a new reference key. (Note: this works only if fields in entry begin on separate lines prior to calling `bibtex-clean-entry' or if -'realign is contained in `bibtex-entry-format'.) +`realign' is contained in `bibtex-entry-format'.) Don't call `bibtex-clean-entry' on @Preamble entries. At end of the cleaning process, the functions in `bibtex-clean-entry-hook' are called with region narrowed to entry." @@ -5009,10 +5047,10 @@ At end of the cleaning process, the functions in (user-error "Not inside a BibTeX entry"))) (entry-type (bibtex-type-in-head)) (key (bibtex-key-in-head))) - (cond ((bibtex-string= entry-type "preamble") + (cond ((string-equal-ignore-case entry-type "preamble") ;; (bibtex-format-preamble) (user-error "No clean up of @Preamble entries")) - ((bibtex-string= entry-type "string") + ((string-equal-ignore-case entry-type "string") (setq entry-type 'string)) ;; (bibtex-format-string) (t (bibtex-format-entry))) @@ -5275,7 +5313,6 @@ entries from minibuffer." (goto-char (point-max)) (message "Buffer is now parsable. Please save it."))) -(define-obsolete-function-alias 'bibtex-complete #'completion-at-point "24.1") (defun bibtex-completion-at-point-function () (let ((pnt (point)) (case-fold-search t) @@ -5290,10 +5327,10 @@ entries from minibuffer." (>= pnt (bibtex-start-of-text-in-field bounds)) (<= pnt (bibtex-end-of-text-in-field bounds))) (setq name (bibtex-name-in-field bounds t) - compl (cond ((bibtex-string= name "crossref") + compl (cond ((string-equal-ignore-case name "crossref") ;; point is in crossref field 'crossref-key) - ((bibtex-string= name "month") + ((string-equal-ignore-case name "month") ;; point is in month field bibtex-predefined-month-strings) ;; point is in other field @@ -5452,7 +5489,7 @@ Return the URL or nil if none can be generated." (while (and (not url) (setq scheme (pop lst))) ;; Verify the match of `bibtex-font-lock-url' by ;; comparing with TEXT. - (when (and (bibtex-string= (caar scheme) name) + (when (and (string-equal-ignore-case (caar scheme) name) (string-match (cdar scheme) text)) (setq url t scheme (cdr scheme))))))) @@ -5608,5 +5645,8 @@ If APPEND is non-nil, append ENTRIES to those already displayed." (setq buffer-read-only t) (goto-char (point-min))) +(define-obsolete-function-alias 'bibtex-find-crossref #'bibtex-search-crossref "29.1") +(define-obsolete-function-alias 'bibtex-find-entry #'bibtex-search-entry "29.1") + (provide 'bibtex) ;;; bibtex.el ends here |