2 |
;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. |
;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. |
3 |
|
|
4 |
;; Author: Carsten Dominik <dominik@science.uva.nl> |
;; Author: Carsten Dominik <dominik@science.uva.nl> |
5 |
;; Version: 4.17 |
;; Version: 4.18 |
6 |
|
|
7 |
;; This file is part of GNU Emacs. |
;; This file is part of GNU Emacs. |
8 |
|
|
164 |
(let* (re-list first-re rest-re |
(let* (re-list first-re rest-re |
165 |
(buffer-list (if (listp buffers) buffers (list buffers))) |
(buffer-list (if (listp buffers) buffers (list buffers))) |
166 |
found-list entry buffer1 buffer alist |
found-list entry buffer1 buffer alist |
167 |
key-point start-point end-point) |
key-point start-point end-point default) |
168 |
|
|
169 |
;; Read a regexp, completing on known citation keys. |
;; Read a regexp, completing on known citation keys. |
170 |
|
(setq default (regexp-quote (reftex-get-bibkey-default))) |
171 |
(setq re-list |
(setq re-list |
172 |
(split-string |
(split-string |
173 |
(completing-read |
(completing-read |
174 |
"RegExp [ && RegExp...]: " |
(concat |
175 |
|
"Regex { && Regex...}: " |
176 |
|
"[" default "]: ") |
177 |
(if reftex-mode |
(if reftex-mode |
178 |
(if (fboundp 'LaTeX-bibitem-list) |
(if (fboundp 'LaTeX-bibitem-list) |
179 |
(LaTeX-bibitem-list) |
(LaTeX-bibitem-list) |
183 |
nil nil nil 'reftex-cite-regexp-hist) |
nil nil nil 'reftex-cite-regexp-hist) |
184 |
"[ \t]*&&[ \t]*")) |
"[ \t]*&&[ \t]*")) |
185 |
|
|
186 |
|
(if (or (null re-list ) (equal re-list '(""))) |
187 |
|
(setq re-list (list default))) |
188 |
|
|
189 |
(setq first-re (car re-list) ; We'll use the first re to find things, |
(setq first-re (car re-list) ; We'll use the first re to find things, |
190 |
rest-re (cdr re-list)) ; the others to narrow down. |
rest-re (cdr re-list)) ; the others to narrow down. |
191 |
(if (string-match "\\`[ \t]*\\'" (or first-re "")) |
(if (string-match "\\`[ \t]*\\'" (or first-re "")) |
321 |
;; Parsing is not as good as for the BibTeX database stuff. |
;; Parsing is not as good as for the BibTeX database stuff. |
322 |
;; The environment should be located in file FILE. |
;; The environment should be located in file FILE. |
323 |
|
|
324 |
(let* (start end buf entries re re-list file) |
(let* (start end buf entries re re-list file default) |
325 |
(unless files |
(unless files |
326 |
(error "Need file name to find thebibliography environment")) |
(error "Need file name to find thebibliography environment")) |
327 |
(while (setq file (pop files)) |
(while (setq file (pop files)) |
357 |
(unless entries |
(unless entries |
358 |
(error "No bibitems found")) |
(error "No bibitems found")) |
359 |
|
|
360 |
(setq re-list (split-string |
;; Read a regexp, completing on known citation keys. |
361 |
(read-string "RegExp [ && RegExp...]: " |
(setq default (regexp-quote (reftex-get-bibkey-default))) |
362 |
nil 'reftex-cite-regexp-hist) |
(setq re-list |
363 |
"[ \t]*&&[ \t]*")) |
(split-string |
364 |
|
(completing-read |
365 |
|
(concat |
366 |
|
"Regex { && Regex...}: " |
367 |
|
"[" default "]: ") |
368 |
|
(if reftex-mode |
369 |
|
(if (fboundp 'LaTeX-bibitem-list) |
370 |
|
(LaTeX-bibitem-list) |
371 |
|
(cdr (assoc 'bibview-cache |
372 |
|
(symbol-value reftex-docstruct-symbol)))) |
373 |
|
nil) |
374 |
|
nil nil nil 'reftex-cite-regexp-hist) |
375 |
|
"[ \t]*&&[ \t]*")) |
376 |
|
|
377 |
|
(if (or (null re-list ) (equal re-list '(""))) |
378 |
|
(setq re-list (list default))) |
379 |
|
|
380 |
(if (string-match "\\`[ \t]*\\'" (car re-list)) |
(if (string-match "\\`[ \t]*\\'" (car re-list)) |
381 |
(error "Empty regular expression")) |
(error "Empty regular expression")) |
382 |
|
|
397 |
|
|
398 |
entries)) |
entries)) |
399 |
|
|
400 |
|
(defun reftex-get-bibkey-default () |
401 |
|
;; Return the word before the cursor. If the cursor is in a |
402 |
|
;; citation macro, return the word before the macro. |
403 |
|
(let* ((macro (reftex-what-macro 1))) |
404 |
|
(save-excursion |
405 |
|
(if (and macro (string-match "cite" (car macro))) |
406 |
|
(goto-char (cdr macro))) |
407 |
|
(skip-chars-backward "^a-zA-Z0-9") |
408 |
|
(reftex-this-word)))) |
409 |
|
|
410 |
;; Parse and format individual entries |
;; Parse and format individual entries |
411 |
|
|
412 |
(defun reftex-get-bib-names (field entry) |
(defun reftex-get-bib-names (field entry) |