changeset 25801:8f6d4157f700

(reftex-pop-to-bibtex-entry): Fixed bug with recentering window. (reftex-extract-bib-entries-from-thebibliography, reftex-offer-bib-menu,reftex-bibtex-selection-callback): Deal with multiple thebibliography environments.
author Carsten Dominik <dominik@science.uva.nl>
date Fri, 24 Sep 1999 09:54:22 +0000
parents 609695887d08
children 4c4fabd16782
files lisp/textmodes/reftex-cite.el
diffstat 1 files changed, 46 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/textmodes/reftex-cite.el	Thu Sep 23 22:17:46 1999 +0000
+++ b/lisp/textmodes/reftex-cite.el	Fri Sep 24 09:54:22 1999 +0000
@@ -80,7 +80,7 @@
 	    (concat "@[a-zA-Z]+[ \t\n\r]*[{(][ \t\n\r]*" (regexp-quote key)
 		    "[, \t\r\n}]")))
 	 (buffer-conf (current-buffer))
-         file buf)
+         file buf pos)
 
     (catch 'exit
       (while file-list
@@ -93,6 +93,7 @@
         (goto-char (point-min))
         (when (re-search-forward re nil t)
           (goto-char (match-beginning 0))
+	  (setq pos (point))
 	  (when return
 	    ;; Just return the relevant entry
 	    (if item (goto-char (match-end 0)))
@@ -101,6 +102,7 @@
 	    (set-buffer buffer-conf)
 	    (throw 'exit return))
 	  (switch-to-buffer-other-window buf)
+	  (goto-char pos)
           (recenter 0)
           (if highlight
               (reftex-highlight 0 (match-beginning 0) (match-end 0)))
@@ -275,42 +277,44 @@
           nil)))))
 
 ;; Parse the thebibliography environment
-(defun reftex-extract-bib-entries-from-thebibliography (file)
+(defun reftex-extract-bib-entries-from-thebibliography (files)
   ;; Extract bib-entries from the \begin{thebibliography} environment.
   ;; Parsing is not as good as for the BibTeX database stuff.
   ;; The environment should be located in file FILE.
 
-  (let* (start end buf entries re re-list)
-    (unless file
+  (let* (start end buf entries re re-list file)
+    (unless files
       (error "Need file name to find thebibliography environment"))
-    (setq buf (reftex-get-file-buffer-force 
-	       file (not reftex-keep-temporary-buffers)))
-    (unless buf
-      (error "No such file %s" file))
-    (message "Scanning thebibliography environment in %s" file)
+    (while (setq file (pop files))
+      (setq buf (reftex-get-file-buffer-force 
+		 file (not reftex-keep-temporary-buffers)))
+      (unless buf
+	(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))
-	(if (re-search-forward 
-	     "\\(\\`\\|[\n\r]\\)[ \t]*\\\\begin{thebibliography}" nil t)
-	    (progn
-	      (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 
-		(mapcar 'reftex-parse-bibitem
-		   (delete ""
-		      (split-string 
-		       (buffer-substring-no-properties start end)
-		       "[ \t\n\r]*\\\\bibitem\\(\\[[^]]*]\\)*")))))))
+      (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)))))
     (unless entries
       (error "No bibitems found"))
 
@@ -666,7 +670,10 @@
 	       ((assq 'thebib (symbol-value reftex-docstruct-symbol))
 		;; using thebibliography environment.
 		(reftex-extract-bib-entries-from-thebibliography
-		 (cdr (assq 'thebib (symbol-value reftex-docstruct-symbol)))))
+		 (reftex-uniquify
+		  (mapcar 'cdr
+			  (reftex-all-assq 
+			   'thebib (symbol-value reftex-docstruct-symbol))))))
 	       (reftex-default-bibliography
 		(message "Using default bibliography")
 		(reftex-extract-bib-entries (reftex-default-bibliography)))
@@ -900,7 +907,7 @@
   ;; recommended for follow mode.  It works OK for individual lookups.
   (let ((win (selected-window))
         (key (reftex-get-bib-field "&key" data))
-        bibfile-list item tmp)
+        bibfile-list item)
 
     (catch 'exit
       (save-excursion
@@ -908,8 +915,12 @@
 	(cond
 	 ((assq 'bib (symbol-value reftex-docstruct-symbol))
 	  (setq bibfile-list (reftex-get-bibfile-list)))
-	 ((setq tmp (assq 'thebib (symbol-value reftex-docstruct-symbol)))
-	  (setq bibfile-list (list (cdr tmp))
+	 ((assq 'thebib (symbol-value reftex-docstruct-symbol))
+	  (setq bibfile-list
+		(reftex-uniquify
+		 (mapcar 'cdr
+			 (reftex-all-assq 
+			  'thebib (symbol-value reftex-docstruct-symbol))))
 		item t))
 	 (reftex-default-bibliography
 	  (setq bibfile-list (reftex-default-bibliography)))