changeset 51416:83476384bebd

(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.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 02 Jun 2003 22:41:50 +0000
parents 762217a72cae
children 0910a521766a
files lisp/textmodes/bibtex.el
diffstat 1 files changed, 13 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- 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