changeset 46973:11e08f9901ea

Update to RefTeX 4.18
author Carsten Dominik <dominik@science.uva.nl>
date Tue, 20 Aug 2002 10:41:01 +0000
parents 88b4ed0b18c9
children c1849e5be7c9
files lisp/textmodes/reftex-cite.el lisp/textmodes/reftex-dcr.el lisp/textmodes/reftex.el
diffstat 3 files changed, 39 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/textmodes/reftex-cite.el	Tue Aug 20 10:07:40 2002 +0000
+++ b/lisp/textmodes/reftex-cite.el	Tue Aug 20 10:41:01 2002 +0000
@@ -74,6 +74,26 @@
 	 reftex-default-bibliography))
   (get 'reftex-default-bibliography :reftex-expanded))
 
+(defun reftex-bib-or-thebib ()
+  ;; Tests if BibTeX or \begin{tehbibliography} should be used for the
+  ;; citation
+  ;; Find the bof of the current file
+  (let* ((docstruct (symbol-value reftex-docstruct-symbol))
+	 (rest (or (member (list 'bof (buffer-file-name)) docstruct)
+		   docstruct))
+	 (bib (assq 'bib rest))
+	 (thebib (assq 'thebib rest))
+	 (bibmem (memq bib rest))
+	 (thebibmem (memq thebib rest)))
+    (when (not (or thebib bib))
+      (setq bib (assq 'bib docstruct)
+	    thebib (assq 'thebib docstruct)
+	    bibmem (memq bib docstruct)
+	    thebibmem (memq thebib docstruct)))
+    (if (> (length bibmem) (length thebibmem))
+	(if bib 'bib nil)
+      (if thebib 'thebib nil))))
+
 (defun reftex-get-bibfile-list ()
   ;; Return list of bibfiles for current document.
   ;; When using the chapterbib or bibunits package you should either
@@ -736,17 +756,20 @@
 (defun reftex-offer-bib-menu ()
   ;; Offer bib menu and return list of selected items
 
-  (let (found-list rtn key data selected-entries)
+  (let ((bibtype (reftex-bib-or-thebib))
+	found-list rtn key data selected-entries)
     (while 
 	(not 
 	 (catch 'done
 	   ;; Scan bibtex files
 	   (setq found-list
 	      (cond
-	       ((assq 'bib (symbol-value reftex-docstruct-symbol))
+	       ((eq bibtype 'bib)
+;	       ((assq 'bib (symbol-value reftex-docstruct-symbol))
 		;; using BibTeX database files.
 		(reftex-extract-bib-entries (reftex-get-bibfile-list)))
-	       ((assq 'thebib (symbol-value reftex-docstruct-symbol))
+	       ((eq bibtype 'thebib)
+;	       ((assq 'thebib (symbol-value reftex-docstruct-symbol))
 		;; using thebibliography environment.
 		(reftex-extract-bib-entries-from-thebibliography
 		 (reftex-uniquify
@@ -987,15 +1010,18 @@
   ;; recommended for follow mode.  It works OK for individual lookups.
   (let ((win (selected-window))
         (key (reftex-get-bib-field "&key" data))
-        bibfile-list item)
+        bibfile-list item bibtype)
 
     (catch 'exit
       (save-excursion
 	(set-buffer reftex-call-back-to-this-buffer)
+	(setq bibtype (reftex-bib-or-thebib))
 	(cond
-	 ((assq 'bib (symbol-value reftex-docstruct-symbol))
+	 ((eq bibtype 'bib)
+;	 ((assq 'bib (symbol-value reftex-docstruct-symbol))
 	  (setq bibfile-list (reftex-get-bibfile-list)))
-	 ((assq 'thebib (symbol-value reftex-docstruct-symbol))
+	 ((eq bibtype 'thebib)
+;	 ((assq 'thebib (symbol-value reftex-docstruct-symbol))
 	  (setq bibfile-list
 		(reftex-uniquify
 		 (mapcar 'cdr
--- a/lisp/textmodes/reftex-dcr.el	Tue Aug 20 10:07:40 2002 +0000
+++ b/lisp/textmodes/reftex-dcr.el	Tue Aug 20 10:41:01 2002 +0000
@@ -116,13 +116,16 @@
       (put 'reftex-auto-view-crossref 'last-window-conf 
 	   (current-window-configuration)))
 
-  (let (files size item (pos (point)) (win (selected-window)) pop-win)
+  (let (files size item (pos (point)) (win (selected-window)) pop-win
+	      (bibtype (reftex-bib-or-thebib)))
     ;; Find the citation mode and the file list
     (cond
-     ((assq 'bib (symbol-value reftex-docstruct-symbol))
+;     ((assq 'bib (symbol-value reftex-docstruct-symbol))
+     ((eq bibtype 'bib)
       (setq item nil
 	    files (reftex-get-bibfile-list)))
-     ((assq 'thebib (symbol-value reftex-docstruct-symbol))
+;     ((assq 'thebib (symbol-value reftex-docstruct-symbol))
+     ((eq bibtype 'thebib)
       (setq item t
 	    files (reftex-uniquify
 		   (mapcar 'cdr
--- a/lisp/textmodes/reftex.el	Tue Aug 20 10:07:40 2002 +0000
+++ b/lisp/textmodes/reftex.el	Tue Aug 20 10:41:01 2002 +0000
@@ -1665,7 +1665,7 @@
 (autoload 'reftex-citation "reftex-cite"
  "Make a citation using BibTeX database files." t)
 (autoload 'reftex-default-bibliography "reftex-cite")
-
+(autoload 'reftex-bib-or-thebib "reftex-cite")
 
 ;;; =========================================================================
 ;;;