# HG changeset patch # User Stefan Monnier # Date 1054593710 0 # Node ID 83476384bebda33aab08b963dc517bb80a7baec6 # Parent 762217a72cae55ad95c595300e8840153df240b8 (bibtex-member-of-regexp, bibtex-assoc-of-regexp, bibtex-format-entry) (bibtex-find-entry, bibtex-autokey-demangle-name, bibtex-string-files-init) (bibtex-mode): Fix up regexp usage and use match-string. diff -r 762217a72cae -r 83476384bebd lisp/textmodes/bibtex.el --- a/lisp/textmodes/bibtex.el Mon Jun 02 22:30:09 2003 +0000 +++ b/lisp/textmodes/bibtex.el Mon Jun 02 22:41:50 2003 +0000 @@ -988,7 +988,7 @@ (defconst bibtex-entry-maybe-empty-head (concat bibtex-entry-head "?") "Regexp matching the header line of a maybe empty BibTeX entry -(possibly without reference key).") +\(possibly without reference key).") (defconst bibtex-type-in-head 1 "Regexp subexpression number of the type part in `bibtex-entry-head'.") @@ -1404,7 +1404,7 @@ The value is actually the tail of LIST whose car matches STRING." (let (case-fold-search) (while (and list - (not (string-match (concat "^" (car list) "$") string))) + (not (string-match (concat "\\`\\(?:" (car list) "\\)\\'") string))) (setq list (cdr list))) list)) @@ -1414,7 +1414,7 @@ of LIST whose car matches STRING." (let ((case-fold-search t)) (while (and alist - (not (string-match (concat "^" (caar alist) "$") string))) + (not (string-match (concat "\\`\\(?:" (caar alist) "\\)\\'") string))) (setq alist (cdr alist))) (car alist))) @@ -1824,7 +1824,7 @@ ;; update page dashes (if (and (memq 'page-dashes format) - (string-match "^\\(OPT\\)?pages\\'" field-name) + (string-match "\\`\\(OPT\\)?pages\\'" field-name) (progn (goto-char beg-text) (looking-at "\\([\"{][0-9]+\\)[ \t\n]*--?[ \t\n]*\\([0-9]+[\"}]\\)"))) @@ -1965,21 +1965,21 @@ ;; Name is of the form "von Last, First" or ;; "von Last, Jr, First" ;; --> Take the first capital part before the comma - (substring fullname (match-beginning 1) (match-end 1))) + (match-string 1 fullname)) ((string-match "\\([^, ]*\\)," fullname) ;; Strange name: we have a comma, but nothing capital ;; So we accept even lowercase names - (substring fullname (match-beginning 1) (match-end 1))) - ((string-match "\\(\\<[a-z][^ ]*[ ]+\\)+\\([A-Z][^ ]*\\)" + (match-string 1 fullname)) + ((string-match "\\(\\<[a-z][^ ]* +\\)+\\([A-Z][^ ]*\\)" fullname) ;; name is of the form "First von Last", "von Last", ;; "First von von Last", or "d'Last" ;; --> take the first capital part after the "von" parts - (substring fullname (match-beginning 2) (match-end 2))) - ((string-match "\\([^ ]+\\)[ ]*$" fullname) + (match-string 2 fullname)) + ((string-match "\\([^ ]+\\) *\\'" fullname) ;; name is of the form "First Middle Last" or "Last" ;; --> take the last token - (substring fullname (match-beginning 1) (match-end 1))) + (match-string 1 fullname)) (t (error "Name `%s' is incorrectly formed" fullname))))) (bibtex-autokey-abbrev (funcall bibtex-autokey-name-case-convert name) @@ -2233,7 +2233,7 @@ (case-fold-search) compl) (dolist (filename bibtex-string-files) - (unless (string-match "\.bib$" filename) + (unless (string-match "\\.bib\\'" filename) (setq filename (concat filename ".bib"))) ;; test filenames (let (fullfilename bounds found) @@ -2523,7 +2523,7 @@ (set (make-local-variable 'comment-start-skip) (concat (regexp-quote bibtex-comment-start) "\\>[ \t]*")) (set (make-local-variable 'comment-column) 0) - (set (make-local-variable 'defun-prompt-regexp) "^[ \t]*@[a-zA-Z0-9]+") + (set (make-local-variable 'defun-prompt-regexp) "^[ \t]*@[a-zA-Z0-9]+[ \t]*") (set (make-local-variable 'outline-regexp) "[ \t]*@") (set (make-local-variable 'fill-prefix) (make-string (+ bibtex-entry-offset bibtex-contline-indentation) @@ -2902,7 +2902,7 @@ (when (re-search-forward (concat "^[ \t]*\\(" bibtex-entry-type "\\)[ \t]*[({][ \t\n]*\\(" - key "\\)") + (regexp-quote key) "\\)") nil t) (match-beginning 2))))) (cond (pnt