aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Dominik1999-09-24 09:54:22 +0000
committerCarsten Dominik1999-09-24 09:54:22 +0000
commit09308e63638e0a3d667622a5220da5e23b5482fc (patch)
treef57bba27230deaa2173cd8e1afa862807a447987
parent7ab1745fb8dbd09b9ff8f33945243041f199f7a6 (diff)
downloademacs-09308e63638e0a3d667622a5220da5e23b5482fc.tar.gz
emacs-09308e63638e0a3d667622a5220da5e23b5482fc.zip
(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.
-rw-r--r--lisp/textmodes/reftex-cite.el81
1 files changed, 46 insertions, 35 deletions
diff --git a/lisp/textmodes/reftex-cite.el b/lisp/textmodes/reftex-cite.el
index afe000785e3..b1d5da9d230 100644
--- a/lisp/textmodes/reftex-cite.el
+++ b/lisp/textmodes/reftex-cite.el
@@ -80,7 +80,7 @@
80 (concat "@[a-zA-Z]+[ \t\n\r]*[{(][ \t\n\r]*" (regexp-quote key) 80 (concat "@[a-zA-Z]+[ \t\n\r]*[{(][ \t\n\r]*" (regexp-quote key)
81 "[, \t\r\n}]"))) 81 "[, \t\r\n}]")))
82 (buffer-conf (current-buffer)) 82 (buffer-conf (current-buffer))
83 file buf) 83 file buf pos)
84 84
85 (catch 'exit 85 (catch 'exit
86 (while file-list 86 (while file-list
@@ -93,6 +93,7 @@
93 (goto-char (point-min)) 93 (goto-char (point-min))
94 (when (re-search-forward re nil t) 94 (when (re-search-forward re nil t)
95 (goto-char (match-beginning 0)) 95 (goto-char (match-beginning 0))
96 (setq pos (point))
96 (when return 97 (when return
97 ;; Just return the relevant entry 98 ;; Just return the relevant entry
98 (if item (goto-char (match-end 0))) 99 (if item (goto-char (match-end 0)))
@@ -101,6 +102,7 @@
101 (set-buffer buffer-conf) 102 (set-buffer buffer-conf)
102 (throw 'exit return)) 103 (throw 'exit return))
103 (switch-to-buffer-other-window buf) 104 (switch-to-buffer-other-window buf)
105 (goto-char pos)
104 (recenter 0) 106 (recenter 0)
105 (if highlight 107 (if highlight
106 (reftex-highlight 0 (match-beginning 0) (match-end 0))) 108 (reftex-highlight 0 (match-beginning 0) (match-end 0)))
@@ -275,42 +277,44 @@
275 nil))))) 277 nil)))))
276 278
277;; Parse the thebibliography environment 279;; Parse the thebibliography environment
278(defun reftex-extract-bib-entries-from-thebibliography (file) 280(defun reftex-extract-bib-entries-from-thebibliography (files)
279 ;; Extract bib-entries from the \begin{thebibliography} environment. 281 ;; Extract bib-entries from the \begin{thebibliography} environment.
280 ;; Parsing is not as good as for the BibTeX database stuff. 282 ;; Parsing is not as good as for the BibTeX database stuff.
281 ;; The environment should be located in file FILE. 283 ;; The environment should be located in file FILE.
282 284
283 (let* (start end buf entries re re-list) 285 (let* (start end buf entries re re-list file)
284 (unless file 286 (unless files
285 (error "Need file name to find thebibliography environment")) 287 (error "Need file name to find thebibliography environment"))
286 (setq buf (reftex-get-file-buffer-force 288 (while (setq file (pop files))
287 file (not reftex-keep-temporary-buffers))) 289 (setq buf (reftex-get-file-buffer-force
288 (unless buf 290 file (not reftex-keep-temporary-buffers)))
289 (error "No such file %s" file)) 291 (unless buf
290 (message "Scanning thebibliography environment in %s" file) 292 (error "No such file %s" file))
293 (message "Scanning thebibliography environment in %s" file)
291 294
292 (save-excursion 295 (save-excursion
293 (set-buffer buf) 296 (set-buffer buf)
294 (save-restriction 297 (save-restriction
295 (widen) 298 (widen)
296 (goto-char (point-min)) 299 (goto-char (point-min))
297 (if (re-search-forward 300 (while (re-search-forward
298 "\\(\\`\\|[\n\r]\\)[ \t]*\\\\begin{thebibliography}" nil t) 301 "\\(\\`\\|[\n\r]\\)[ \t]*\\\\begin{thebibliography}" nil t)
299 (progn 302 (beginning-of-line 2)
300 (beginning-of-line 2) 303 (setq start (point))
301 (setq start (point)))) 304 (if (re-search-forward
302 (if (re-search-forward 305 "\\(\\`\\|[\n\r]\\)[ \t]*\\\\end{thebibliography}" nil t)
303 "\\(\\`\\|[\n\r]\\)[ \t]*\\\\end{thebibliography}" nil t) 306 (progn
304 (progn 307 (beginning-of-line 1)
305 (beginning-of-line 1) 308 (setq end (point))))
306 (setq end (point)))) 309 (when (and start end)
307 (when (and start end) 310 (setq entries
308 (setq entries 311 (append entries
309 (mapcar 'reftex-parse-bibitem 312 (mapcar 'reftex-parse-bibitem
310 (delete "" 313 (delete ""
311 (split-string 314 (split-string
312 (buffer-substring-no-properties start end) 315 (buffer-substring-no-properties start end)
313 "[ \t\n\r]*\\\\bibitem\\(\\[[^]]*]\\)*"))))))) 316 "[ \t\n\r]*\\\\bibitem\\(\\[[^]]*]\\)*"))))))
317 (goto-char end)))))
314 (unless entries 318 (unless entries
315 (error "No bibitems found")) 319 (error "No bibitems found"))
316 320
@@ -666,7 +670,10 @@ While entering the regexp, completion on knows citation keys is possible.
666 ((assq 'thebib (symbol-value reftex-docstruct-symbol)) 670 ((assq 'thebib (symbol-value reftex-docstruct-symbol))
667 ;; using thebibliography environment. 671 ;; using thebibliography environment.
668 (reftex-extract-bib-entries-from-thebibliography 672 (reftex-extract-bib-entries-from-thebibliography
669 (cdr (assq 'thebib (symbol-value reftex-docstruct-symbol))))) 673 (reftex-uniquify
674 (mapcar 'cdr
675 (reftex-all-assq
676 'thebib (symbol-value reftex-docstruct-symbol))))))
670 (reftex-default-bibliography 677 (reftex-default-bibliography
671 (message "Using default bibliography") 678 (message "Using default bibliography")
672 (reftex-extract-bib-entries (reftex-default-bibliography))) 679 (reftex-extract-bib-entries (reftex-default-bibliography)))
@@ -900,7 +907,7 @@ While entering the regexp, completion on knows citation keys is possible.
900 ;; recommended for follow mode. It works OK for individual lookups. 907 ;; recommended for follow mode. It works OK for individual lookups.
901 (let ((win (selected-window)) 908 (let ((win (selected-window))
902 (key (reftex-get-bib-field "&key" data)) 909 (key (reftex-get-bib-field "&key" data))
903 bibfile-list item tmp) 910 bibfile-list item)
904 911
905 (catch 'exit 912 (catch 'exit
906 (save-excursion 913 (save-excursion
@@ -908,8 +915,12 @@ While entering the regexp, completion on knows citation keys is possible.
908 (cond 915 (cond
909 ((assq 'bib (symbol-value reftex-docstruct-symbol)) 916 ((assq 'bib (symbol-value reftex-docstruct-symbol))
910 (setq bibfile-list (reftex-get-bibfile-list))) 917 (setq bibfile-list (reftex-get-bibfile-list)))
911 ((setq tmp (assq 'thebib (symbol-value reftex-docstruct-symbol))) 918 ((assq 'thebib (symbol-value reftex-docstruct-symbol))
912 (setq bibfile-list (list (cdr tmp)) 919 (setq bibfile-list
920 (reftex-uniquify
921 (mapcar 'cdr
922 (reftex-all-assq
923 'thebib (symbol-value reftex-docstruct-symbol))))
913 item t)) 924 item t))
914 (reftex-default-bibliography 925 (reftex-default-bibliography
915 (setq bibfile-list (reftex-default-bibliography))) 926 (setq bibfile-list (reftex-default-bibliography)))