+2002-08-20 Carsten Dominik <dominik@astro.uva.nl>
+
+ * textfiles/reftex-cite.el (reftex-bib-or-thebib): New function
+ which determines on a per-file-basis if BibTeX is being used
+ locally for citations.
+ (reftex-offer-bib-menu): Use `reftex-bib-or-thebib' for better
+ cooperation with chapterbib.
+ (reftex-bibtex-selection-callback): Use `reftex-bib-or-thebib' for
+ better cooperation with chapterbib.
+
+ * textfiles/reftex-dcr.el (reftex-view-cr-cite): Use
+ `reftex-bib-or-thebib' for better cooperation with chapterbib.
+
+
2002-08-20 Kim F. Storm <storm@cua.dk>
* kmacro.el: Major rework based on discussions with RMS.
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
(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
;; 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
(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