]> code.delx.au - gnu-emacs/blobdiff - lisp/textmodes/reftex-cite.el
Convert consecutive FSF copyright years to ranges.
[gnu-emacs] / lisp / textmodes / reftex-cite.el
index c81d20fb4e181ce01a92c6e3882a35b1ed0ed17e..78d80da41acf69d3717ba7514d7d5a26900f8fb3 100644 (file)
@@ -1,11 +1,11 @@
 ;;; reftex-cite.el --- creating citations with RefTeX
 
-;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-;;   2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2011 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <dominik@science.uva.nl>
 ;; Maintainer: auctex-devel@gnu.org
 ;; Version: 4.31
+;; Package: reftex
 
 ;; This file is part of GNU Emacs.
 
         (error "No such file %s" file))
       (message "Scanning thebibliography environment in %s" file)
 
-      (save-excursion
-        (set-buffer buf)
-        (save-restriction
-          (widen)
-          (goto-char (point-min))
-          (while (re-search-forward 
-                  "\\(\\`\\|[\n\r]\\)[ \t]*\\\\begin{thebibliography}" nil t)
-            (beginning-of-line 2)
-            (setq start (point))
-            (if (re-search-forward 
-                 "\\(\\`\\|[\n\r]\\)[ \t]*\\\\end{thebibliography}" nil t)
-                (progn
-                  (beginning-of-line 1)
-                  (setq end (point))))
-            (when (and start end)
-              (setq entries 
-                    (append entries
-                      (mapcar 'reftex-parse-bibitem
-                        (delete ""
-                                (split-string 
-                                 (buffer-substring-no-properties start end)
-                                 "[ \t\n\r]*\\\\bibitem\\(\\[[^]]*]\\)*"))))))
-            (goto-char end)))))
+      (with-current-buffer buf
+       (save-excursion
+         (save-restriction
+           (widen)
+           (goto-char (point-min))
+           (while (re-search-forward
+                   "\\(\\`\\|[\n\r]\\)[ \t]*\\\\begin{thebibliography}" nil t)
+             (beginning-of-line 2)
+             (setq start (point))
+             (if (re-search-forward
+                  "\\(\\`\\|[\n\r]\\)[ \t]*\\\\end{thebibliography}" nil t)
+                 (progn
+                   (beginning-of-line 1)
+                   (setq end (point))))
+             (when (and start end)
+               (setq entries
+                     (append entries
+                             (mapcar 'reftex-parse-bibitem
+                                     (delete ""
+                                             (split-string
+                                              (buffer-substring-no-properties
+                                               start end)
+                                              "[ \t\n\r]*\\\\bibitem[ \t]*\
+\\(\\[[^]]*]\\)*\[ \t]*"))))))
+             (goto-char end))))))
     (unless entries
       (error "No bibitems found"))
 
@@ -1076,8 +1078,7 @@ While entering the regexp, completion on knows citation keys is possible.
         bibfile-list item bibtype)
 
     (catch 'exit
-      (save-excursion
-        (set-buffer reftex-call-back-to-this-buffer)
+      (with-current-buffer reftex-call-back-to-this-buffer
         (setq bibtype (reftex-bib-or-thebib))
         (cond
          ((eq bibtype 'bib)
@@ -1109,7 +1110,7 @@ While entering the regexp, completion on knows citation keys is possible.
 (defun reftex-all-used-citation-keys ()
   (reftex-access-scan-info)
   (let ((files (reftex-all-document-files)) file keys kk k)
-    (save-excursion
+    (save-current-buffer
       (while (setq file (pop files))
         (set-buffer (reftex-get-file-buffer-force file 'mark))
         (save-excursion
@@ -1137,7 +1138,7 @@ The sequence in the new file is the same as it was in the old database."
   (let ((keys (reftex-all-used-citation-keys))
         (files (reftex-get-bibfile-list))
         file key entries beg end entry)
-    (save-excursion
+    (save-current-buffer
       (while (setq file (pop files))
         (set-buffer (reftex-get-file-buffer-force file 'mark))
         (reftex-with-special-syntax-for-bib
@@ -1145,9 +1146,8 @@ The sequence in the new file is the same as it was in the old database."
            (save-restriction
              (widen)
              (goto-char (point-min))
-             (while (re-search-forward
-                     "^[ \t]*@[a-zA-Z]+[ \t]*{\\([^ \t\r\n]+\\),"
-                     nil t)
+             (while (re-search-forward "^[ \t]*@\\(?:\\w\\|\\s_\\)+[ \t\n\r]*\
+\[{(][ \t\n\r]*\\([^ \t\n\r,]+\\)" nil t)
                (setq key (match-string 1)
                      beg (match-beginning 0)
                      end (progn
@@ -1173,5 +1173,4 @@ The sequence in the new file is the same as it was in the old database."
              (length entries))))
 
 
-;; arch-tag: d53d0a5a-ab32-4b52-a846-2a7c3527cd89
 ;;; reftex-cite.el ends here