Mercurial > emacs
annotate lisp/textmodes/reftex-cite.el @ 63092:80ef8a2a052d
(debug): Don't bury the buffer unless it's in a dedicated window.
| author | Stefan Monnier <monnier@iro.umontreal.ca> |
|---|---|
| date | Mon, 06 Jun 2005 19:47:05 +0000 |
| parents | 35f6599373fc |
| children | a8fa7c632ee4 f042e7c0fe20 |
| rev | line source |
|---|---|
|
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Jan?k <Pavel@Janik.cz>
parents:
37998
diff
changeset
|
1 ;;; reftex-cite.el --- creating citations with RefTeX |
|
60918
58a53f588384
* textmodes/refbib.el, textmodes/refer.el, textmodes/reftex-cite.el,
Werner LEMBERG <wl@gnu.org>
parents:
60056
diff
changeset
|
2 ;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004, 2005 |
|
58a53f588384
* textmodes/refbib.el, textmodes/refer.el, textmodes/reftex-cite.el,
Werner LEMBERG <wl@gnu.org>
parents:
60056
diff
changeset
|
3 ;; Free Software Foundation, Inc. |
| 27035 | 4 |
|
46612
7522419c4db0
Updated to reftex 4.17
Carsten Dominik <dominik@science.uva.nl>
parents:
46131
diff
changeset
|
5 ;; Author: Carsten Dominik <dominik@science.uva.nl> |
|
62467
35f6599373fc
* textmodes/reftex-vars.el (reftex-cite-format-builtin): Support
Carsten Dominik <dominik@science.uva.nl>
parents:
62402
diff
changeset
|
6 ;; Version: 4.28 |
| 27035 | 7 |
| 8 ;; This file is part of GNU Emacs. | |
| 9 | |
| 10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
| 11 ;; it under the terms of the GNU General Public License as published by | |
| 12 ;; the Free Software Foundation; either version 2, or (at your option) | |
| 13 ;; any later version. | |
| 14 | |
| 15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
| 16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 18 ;; GNU General Public License for more details. | |
| 19 | |
| 20 ;; You should have received a copy of the GNU General Public License | |
| 21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
| 22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
| 23 ;; Boston, MA 02111-1307, USA. | |
| 25280 | 24 |
|
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Jan?k <Pavel@Janik.cz>
parents:
37998
diff
changeset
|
25 ;;; Commentary: |
|
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Jan?k <Pavel@Janik.cz>
parents:
37998
diff
changeset
|
26 |
|
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Jan?k <Pavel@Janik.cz>
parents:
37998
diff
changeset
|
27 ;;; Code: |
|
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Jan?k <Pavel@Janik.cz>
parents:
37998
diff
changeset
|
28 |
|
26910
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25806
diff
changeset
|
29 (eval-when-compile (require 'cl)) |
| 25280 | 30 (provide 'reftex-cite) |
| 31 (require 'reftex) | |
| 32 ;;; | |
| 33 | |
| 34 ;; Variables and constants | |
| 35 | |
| 36 ;; The history list of regular expressions used for citations | |
| 37 (defvar reftex-cite-regexp-hist nil) | |
| 38 | |
| 39 ;; Prompt and help string for citation selection | |
| 40 (defconst reftex-citation-prompt | |
| 41 "Select: [n]ext [p]revious [r]estrict [ ]full_entry [q]uit RET [?]Help+more") | |
| 42 | |
| 43 (defconst reftex-citation-help | |
| 44 " n / p Go to next/previous entry (Cursor motion works as well). | |
| 45 g / r Start over with new regexp / Refine with additional regexp. | |
| 46 SPC Show full database entry in other window. | |
| 47 f Toggle follow mode: Other window will follow with full db entry. | |
| 48 . Show insertion point. | |
| 49 q Quit without inserting \\cite macro into buffer. | |
| 50 TAB Enter citation key with completion. | |
| 51 RET Accept current entry (also on mouse-2) and create \\cite macro. | |
| 52 m / u Mark/Unmark the entry. | |
|
59534
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
53 e / E Create BibTeX file with all (marked/unmarked) entries |
| 25280 | 54 a / A Put all (marked) entries into one/many \\cite commands.") |
| 55 | |
| 56 ;; Find bibtex files | |
| 57 | |
|
46612
7522419c4db0
Updated to reftex 4.17
Carsten Dominik <dominik@science.uva.nl>
parents:
46131
diff
changeset
|
58 (defmacro reftex-with-special-syntax-for-bib (&rest body) |
|
7522419c4db0
Updated to reftex 4.17
Carsten Dominik <dominik@science.uva.nl>
parents:
46131
diff
changeset
|
59 `(let ((saved-syntax (syntax-table))) |
|
7522419c4db0
Updated to reftex 4.17
Carsten Dominik <dominik@science.uva.nl>
parents:
46131
diff
changeset
|
60 (unwind-protect |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
61 (progn |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
62 (set-syntax-table reftex-syntax-table-for-bib) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
63 ,@body) |
|
46612
7522419c4db0
Updated to reftex 4.17
Carsten Dominik <dominik@science.uva.nl>
parents:
46131
diff
changeset
|
64 (set-syntax-table saved-syntax)))) |
|
7522419c4db0
Updated to reftex 4.17
Carsten Dominik <dominik@science.uva.nl>
parents:
46131
diff
changeset
|
65 |
| 25280 | 66 (defun reftex-default-bibliography () |
| 67 ;; Return the expanded value of `reftex-default-bibliography'. | |
| 68 ;; The expanded value is cached. | |
| 69 (unless (eq (get 'reftex-default-bibliography :reftex-raw) | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
70 reftex-default-bibliography) |
| 25280 | 71 (put 'reftex-default-bibliography :reftex-expanded |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
72 (reftex-locate-bibliography-files |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
73 default-directory reftex-default-bibliography)) |
| 25280 | 74 (put 'reftex-default-bibliography :reftex-raw |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
75 reftex-default-bibliography)) |
| 25280 | 76 (get 'reftex-default-bibliography :reftex-expanded)) |
| 77 | |
|
46973
11e08f9901ea
Update to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
78 (defun reftex-bib-or-thebib () |
|
11e08f9901ea
Update to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
79 ;; Tests if BibTeX or \begin{tehbibliography} should be used for the |
|
11e08f9901ea
Update to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
80 ;; citation |
|
11e08f9901ea
Update to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
81 ;; Find the bof of the current file |
|
11e08f9901ea
Update to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
82 (let* ((docstruct (symbol-value reftex-docstruct-symbol)) |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
83 (rest (or (member (list 'bof (buffer-file-name)) docstruct) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
84 docstruct)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
85 (bib (assq 'bib rest)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
86 (thebib (assq 'thebib rest)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
87 (bibmem (memq bib rest)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
88 (thebibmem (memq thebib rest))) |
|
46973
11e08f9901ea
Update to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
89 (when (not (or thebib bib)) |
|
11e08f9901ea
Update to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
90 (setq bib (assq 'bib docstruct) |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
91 thebib (assq 'thebib docstruct) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
92 bibmem (memq bib docstruct) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
93 thebibmem (memq thebib docstruct))) |
|
46973
11e08f9901ea
Update to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
94 (if (> (length bibmem) (length thebibmem)) |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
95 (if bib 'bib nil) |
|
46973
11e08f9901ea
Update to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
96 (if thebib 'thebib nil)))) |
|
11e08f9901ea
Update to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
97 |
| 25280 | 98 (defun reftex-get-bibfile-list () |
| 99 ;; Return list of bibfiles for current document. | |
| 100 ;; When using the chapterbib or bibunits package you should either | |
| 101 ;; use the same database files everywhere, or separate parts using | |
| 102 ;; different databases into different files (included into the mater file). | |
| 103 ;; Then this function will return the applicable database files. | |
| 104 | |
| 105 ;; Ensure access to scanning info | |
| 106 (reftex-access-scan-info) | |
| 107 (or | |
| 108 ;; Try inside this file (and its includes) | |
| 109 (cdr (reftex-last-assoc-before-elt | |
| 110 'bib (list 'eof (buffer-file-name)) | |
| 111 (member (list 'bof (buffer-file-name)) | |
| 112 (symbol-value reftex-docstruct-symbol)))) | |
| 113 ;; Try after the beginning of this file | |
| 114 (cdr (assq 'bib (member (list 'bof (buffer-file-name)) | |
| 115 (symbol-value reftex-docstruct-symbol)))) | |
| 116 ;; Anywhere in the entire document | |
| 117 (cdr (assq 'bib (symbol-value reftex-docstruct-symbol))) | |
| 118 (error "\\bibliography statement missing or .bib files not found"))) | |
| 119 | |
| 120 ;; Find a certain reference in any of the BibTeX files. | |
| 121 | |
| 122 (defun reftex-pop-to-bibtex-entry (key file-list &optional mark-to-kill | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
123 highlight item return) |
| 25280 | 124 ;; Find BibTeX KEY in any file in FILE-LIST in another window. |
| 125 ;; If MARK-TO-KILL is non-nil, mark new buffer to kill. | |
| 126 ;; If HIGHLIGHT is non-nil, highlight the match. | |
| 127 ;; If ITEM in non-nil, search for bibitem instead of database entry. | |
| 128 ;; If RETURN is non-nil, just return the entry. | |
| 129 | |
| 130 (let* ((re | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
131 (if item |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
132 (concat "\\\\bibitem\\(\\[[^]]*\\]\\)?{" (regexp-quote key) "}") |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
133 (concat "@[a-zA-Z]+[ \t\n\r]*[{(][ \t\n\r]*" (regexp-quote key) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
134 "[, \t\r\n}]"))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
135 (buffer-conf (current-buffer)) |
|
25801
8f6d4157f700
(reftex-pop-to-bibtex-entry): Fixed bug with recentering window.
Carsten Dominik <dominik@science.uva.nl>
parents:
25280
diff
changeset
|
136 file buf pos) |
| 25280 | 137 |
| 138 (catch 'exit | |
| 139 (while file-list | |
| 140 (setq file (car file-list) | |
| 141 file-list (cdr file-list)) | |
| 142 (unless (setq buf (reftex-get-file-buffer-force file mark-to-kill)) | |
| 143 (error "No such file %s" file)) | |
| 144 (set-buffer buf) | |
| 145 (widen) | |
| 146 (goto-char (point-min)) | |
| 147 (when (re-search-forward re nil t) | |
| 148 (goto-char (match-beginning 0)) | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
149 (setq pos (point)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
150 (when return |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
151 ;; Just return the relevant entry |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
152 (if item (goto-char (match-end 0))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
153 (setq return (buffer-substring |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
154 (point) (reftex-end-of-bib-entry item))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
155 (set-buffer buffer-conf) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
156 (throw 'exit return)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
157 (switch-to-buffer-other-window buf) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
158 (goto-char pos) |
| 25280 | 159 (recenter 0) |
| 160 (if highlight | |
| 161 (reftex-highlight 0 (match-beginning 0) (match-end 0))) | |
| 162 (throw 'exit (selected-window)))) | |
| 163 (set-buffer buffer-conf) | |
| 164 (if item | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
165 (error "No \\bibitem with citation key %s" key) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
166 (error "No BibTeX entry with citation key %s" key))))) |
| 25280 | 167 |
| 168 (defun reftex-end-of-bib-entry (item) | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
169 (save-excursion |
| 25280 | 170 (condition-case nil |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
171 (if item |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
172 (progn (end-of-line) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
173 (re-search-forward |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
174 "\\\\bibitem\\|\\end{thebibliography}") |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
175 (1- (match-beginning 0))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
176 (progn (forward-list 1) (point))) |
| 25280 | 177 (error (min (point-max) (+ 300 (point))))))) |
| 178 | |
| 179 ;; Parse bibtex buffers | |
| 180 | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
181 (defun reftex-extract-bib-entries (buffers) |
| 25280 | 182 ;; Extract bib entries which match regexps from BUFFERS. |
| 183 ;; BUFFERS is a list of buffers or file names. | |
| 184 ;; Return list with entries." | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
185 (let* (re-list first-re rest-re |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
186 (buffer-list (if (listp buffers) buffers (list buffers))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
187 found-list entry buffer1 buffer alist |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
188 key-point start-point end-point default) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
189 |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
190 ;; Read a regexp, completing on known citation keys. |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
191 (setq default (regexp-quote (reftex-get-bibkey-default))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
192 (setq re-list |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
193 (split-string |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
194 (completing-read |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
195 (concat |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
196 "Regex { && Regex...}: " |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
197 "[" default "]: ") |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
198 (if reftex-mode |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
199 (if (fboundp 'LaTeX-bibitem-list) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
200 (LaTeX-bibitem-list) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
201 (cdr (assoc 'bibview-cache |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
202 (symbol-value reftex-docstruct-symbol)))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
203 nil) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
204 nil nil nil 'reftex-cite-regexp-hist) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
205 "[ \t]*&&[ \t]*")) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
206 |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
207 (if (or (null re-list ) (equal re-list '(""))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
208 (setq re-list (list default))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
209 |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
210 (setq first-re (car re-list) ; We'll use the first re to find things, |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
211 rest-re (cdr re-list)) ; the others to narrow down. |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
212 (if (string-match "\\`[ \t]*\\'" (or first-re "")) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
213 (error "Empty regular expression")) |
| 25280 | 214 |
| 215 (save-excursion | |
| 216 (save-window-excursion | |
| 217 | |
| 218 ;; Walk through all bibtex files | |
| 219 (while buffer-list | |
| 220 (setq buffer (car buffer-list) | |
| 221 buffer-list (cdr buffer-list)) | |
| 222 (if (and (bufferp buffer) | |
| 223 (buffer-live-p buffer)) | |
| 224 (setq buffer1 buffer) | |
| 225 (setq buffer1 (reftex-get-file-buffer-force | |
| 226 buffer (not reftex-keep-temporary-buffers)))) | |
| 227 (if (not buffer1) | |
| 228 (message "No such BibTeX file %s (ignored)" buffer) | |
| 229 (message "Scanning bibliography database %s" buffer1)) | |
| 230 | |
| 231 (set-buffer buffer1) | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
232 (reftex-with-special-syntax-for-bib |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
233 (save-excursion |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
234 (goto-char (point-min)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
235 (while (re-search-forward first-re nil t) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
236 (catch 'search-again |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
237 (setq key-point (point)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
238 (unless (re-search-backward |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
239 "\\(\\`\\|[\n\r]\\)[ \t]*@\\([a-zA-Z]+\\)[ \t\n\r]*[{(]" nil t) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
240 (throw 'search-again nil)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
241 (setq start-point (point)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
242 (goto-char (match-end 0)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
243 (condition-case nil |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
244 (up-list 1) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
245 (error (goto-char key-point) |
| 25280 | 246 (throw 'search-again nil))) |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
247 (setq end-point (point)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
248 |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
249 ;; Ignore @string, @comment and @c entries or things |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
250 ;; outside entries |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
251 (when (or (string= (downcase (match-string 2)) "string") |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
252 (string= (downcase (match-string 2)) "comment") |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
253 (string= (downcase (match-string 2)) "c") |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
254 (< (point) key-point)) ; this means match not in {} |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
255 (goto-char key-point) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
256 (throw 'search-again nil)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
257 |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
258 ;; Well, we have got a match |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
259 ;;(setq entry (concat |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
260 ;; (buffer-substring start-point (point)) "\n")) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
261 (setq entry (buffer-substring start-point (point))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
262 |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
263 ;; Check if other regexp match as well |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
264 (setq re-list rest-re) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
265 (while re-list |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
266 (unless (string-match (car re-list) entry) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
267 ;; nope - move on |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
268 (throw 'search-again nil)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
269 (pop re-list)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
270 |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
271 (setq alist (reftex-parse-bibtex-entry |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
272 nil start-point end-point)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
273 (push (cons "&entry" entry) alist) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
274 |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
275 ;; check for crossref entries |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
276 (if (assoc "crossref" alist) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
277 (setq alist |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
278 (append |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
279 alist (reftex-get-crossref-alist alist)))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
280 |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
281 ;; format the entry |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
282 (push (cons "&formatted" (reftex-format-bib-entry alist)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
283 alist) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
284 |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
285 ;; make key the first element |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
286 (push (reftex-get-bib-field "&key" alist) alist) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
287 |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
288 ;; add it to the list |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
289 (push alist found-list))))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
290 (reftex-kill-temporary-buffers)))) |
| 25280 | 291 (setq found-list (nreverse found-list)) |
| 292 | |
| 293 ;; Sorting | |
| 294 (cond | |
| 295 ((eq 'author reftex-sort-bibtex-matches) | |
| 296 (sort found-list 'reftex-bib-sort-author)) | |
| 297 ((eq 'year reftex-sort-bibtex-matches) | |
| 298 (sort found-list 'reftex-bib-sort-year)) | |
| 299 ((eq 'reverse-year reftex-sort-bibtex-matches) | |
| 300 (sort found-list 'reftex-bib-sort-year-reverse)) | |
| 301 (t found-list)))) | |
| 302 | |
| 303 (defun reftex-bib-sort-author (e1 e2) | |
| 304 (let ((al1 (reftex-get-bib-names "author" e1)) | |
| 305 (al2 (reftex-get-bib-names "author" e2))) | |
| 306 (while (and al1 al2 (string= (car al1) (car al2))) | |
| 307 (pop al1) | |
| 308 (pop al2)) | |
| 309 (if (and (stringp (car al1)) | |
| 310 (stringp (car al2))) | |
| 311 (string< (car al1) (car al2)) | |
| 312 (not (stringp (car al1)))))) | |
| 313 | |
| 314 (defun reftex-bib-sort-year (e1 e2) | |
|
62402
a7e02ef1e3d6
Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents:
60918
diff
changeset
|
315 (< (string-to-number (or (cdr (assoc "year" e1)) "0")) |
|
a7e02ef1e3d6
Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents:
60918
diff
changeset
|
316 (string-to-number (or (cdr (assoc "year" e2)) "0")))) |
| 25280 | 317 |
| 318 (defun reftex-bib-sort-year-reverse (e1 e2) | |
|
62402
a7e02ef1e3d6
Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents:
60918
diff
changeset
|
319 (> (string-to-number (or (cdr (assoc "year" e1)) "0")) |
|
a7e02ef1e3d6
Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents:
60918
diff
changeset
|
320 (string-to-number (or (cdr (assoc "year" e2)) "0")))) |
| 25280 | 321 |
| 322 (defun reftex-get-crossref-alist (entry) | |
| 323 ;; return the alist from a crossref entry | |
| 324 (let ((crkey (cdr (assoc "crossref" entry))) | |
| 325 start) | |
| 326 (save-excursion | |
| 327 (save-restriction | |
| 328 (widen) | |
| 329 (if (re-search-forward | |
| 330 (concat "@\\w+[{(][ \t\n\r]*" (regexp-quote crkey) | |
| 331 "[ \t\n\r]*,") nil t) | |
| 332 (progn | |
| 333 (setq start (match-beginning 0)) | |
| 334 (condition-case nil | |
| 335 (up-list 1) | |
| 336 (error nil)) | |
| 337 (reftex-parse-bibtex-entry nil start (point))) | |
| 338 nil))))) | |
| 339 | |
| 45318 | 340 ;; Parse the bibliography environment |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
341 (defun reftex-extract-bib-entries-from-thebibliography (files) |
| 25280 | 342 ;; Extract bib-entries from the \begin{thebibliography} environment. |
| 343 ;; Parsing is not as good as for the BibTeX database stuff. | |
| 344 ;; The environment should be located in file FILE. | |
| 345 | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
346 (let* (start end buf entries re re-list file default) |
|
25801
8f6d4157f700
(reftex-pop-to-bibtex-entry): Fixed bug with recentering window.
Carsten Dominik <dominik@science.uva.nl>
parents:
25280
diff
changeset
|
347 (unless files |
| 25280 | 348 (error "Need file name to find thebibliography environment")) |
|
25801
8f6d4157f700
(reftex-pop-to-bibtex-entry): Fixed bug with recentering window.
Carsten Dominik <dominik@science.uva.nl>
parents:
25280
diff
changeset
|
349 (while (setq file (pop files)) |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
350 (setq buf (reftex-get-file-buffer-force |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
351 file (not reftex-keep-temporary-buffers))) |
|
25801
8f6d4157f700
(reftex-pop-to-bibtex-entry): Fixed bug with recentering window.
Carsten Dominik <dominik@science.uva.nl>
parents:
25280
diff
changeset
|
352 (unless buf |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
353 (error "No such file %s" file)) |
|
25801
8f6d4157f700
(reftex-pop-to-bibtex-entry): Fixed bug with recentering window.
Carsten Dominik <dominik@science.uva.nl>
parents:
25280
diff
changeset
|
354 (message "Scanning thebibliography environment in %s" file) |
| 25280 | 355 |
|
25801
8f6d4157f700
(reftex-pop-to-bibtex-entry): Fixed bug with recentering window.
Carsten Dominik <dominik@science.uva.nl>
parents:
25280
diff
changeset
|
356 (save-excursion |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
357 (set-buffer buf) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
358 (save-restriction |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
359 (widen) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
360 (goto-char (point-min)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
361 (while (re-search-forward |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
362 "\\(\\`\\|[\n\r]\\)[ \t]*\\\\begin{thebibliography}" nil t) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
363 (beginning-of-line 2) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
364 (setq start (point)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
365 (if (re-search-forward |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
366 "\\(\\`\\|[\n\r]\\)[ \t]*\\\\end{thebibliography}" nil t) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
367 (progn |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
368 (beginning-of-line 1) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
369 (setq end (point)))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
370 (when (and start end) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
371 (setq entries |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
372 (append entries |
|
25801
8f6d4157f700
(reftex-pop-to-bibtex-entry): Fixed bug with recentering window.
Carsten Dominik <dominik@science.uva.nl>
parents:
25280
diff
changeset
|
373 (mapcar 'reftex-parse-bibitem |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
374 (delete "" |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
375 (split-string |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
376 (buffer-substring-no-properties start end) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
377 "[ \t\n\r]*\\\\bibitem\\(\\[[^]]*]\\)*")))))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
378 (goto-char end))))) |
| 25280 | 379 (unless entries |
| 380 (error "No bibitems found")) | |
| 381 | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
382 ;; Read a regexp, completing on known citation keys. |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
383 (setq default (regexp-quote (reftex-get-bibkey-default))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
384 (setq re-list |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
385 (split-string |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
386 (completing-read |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
387 (concat |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
388 "Regex { && Regex...}: " |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
389 "[" default "]: ") |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
390 (if reftex-mode |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
391 (if (fboundp 'LaTeX-bibitem-list) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
392 (LaTeX-bibitem-list) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
393 (cdr (assoc 'bibview-cache |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
394 (symbol-value reftex-docstruct-symbol)))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
395 nil) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
396 nil nil nil 'reftex-cite-regexp-hist) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
397 "[ \t]*&&[ \t]*")) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
398 |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
399 (if (or (null re-list ) (equal re-list '(""))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
400 (setq re-list (list default))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
401 |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
402 (if (string-match "\\`[ \t]*\\'" (car re-list)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
403 (error "Empty regular expression")) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
404 |
| 25280 | 405 (while (and (setq re (pop re-list)) entries) |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
406 (setq entries |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
407 (delq nil (mapcar |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
408 (lambda (x) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
409 (if (string-match re (cdr (assoc "&entry" x))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
410 x nil)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
411 entries)))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
412 (setq entries |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
413 (mapcar |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
414 (lambda (x) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
415 (push (cons "&formatted" (reftex-format-bibitem x)) x) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
416 (push (reftex-get-bib-field "&key" x) x) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
417 x) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
418 entries)) |
| 25280 | 419 |
| 420 entries)) | |
| 421 | |
|
46683
060f433ebf11
Updated to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents:
46612
diff
changeset
|
422 (defun reftex-get-bibkey-default () |
|
060f433ebf11
Updated to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents:
46612
diff
changeset
|
423 ;; Return the word before the cursor. If the cursor is in a |
|
060f433ebf11
Updated to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents:
46612
diff
changeset
|
424 ;; citation macro, return the word before the macro. |
|
060f433ebf11
Updated to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents:
46612
diff
changeset
|
425 (let* ((macro (reftex-what-macro 1))) |
|
060f433ebf11
Updated to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents:
46612
diff
changeset
|
426 (save-excursion |
|
060f433ebf11
Updated to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents:
46612
diff
changeset
|
427 (if (and macro (string-match "cite" (car macro))) |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
428 (goto-char (cdr macro))) |
|
46683
060f433ebf11
Updated to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents:
46612
diff
changeset
|
429 (skip-chars-backward "^a-zA-Z0-9") |
|
060f433ebf11
Updated to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents:
46612
diff
changeset
|
430 (reftex-this-word)))) |
|
060f433ebf11
Updated to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents:
46612
diff
changeset
|
431 |
| 25280 | 432 ;; Parse and format individual entries |
| 433 | |
| 434 (defun reftex-get-bib-names (field entry) | |
| 435 ;; Return a list with the author or editor names in ENTRY | |
| 436 (let ((names (reftex-get-bib-field field entry))) | |
| 437 (if (equal "" names) | |
| 438 (setq names (reftex-get-bib-field "editor" entry))) | |
| 439 (while (string-match "\\band\\b[ \t]*" names) | |
| 440 (setq names (replace-match "\n" nil t names))) | |
| 441 (while (string-match "[\\.a-zA-Z\\-]+\\.[ \t]*\\|,.*\\|[{}]+" names) | |
| 442 (setq names (replace-match "" nil t names))) | |
| 443 (while (string-match "^[ \t]+\\|[ \t]+$" names) | |
| 444 (setq names (replace-match "" nil t names))) | |
| 445 (while (string-match "[ \t][ \t]+" names) | |
| 446 (setq names (replace-match " " nil t names))) | |
| 447 (split-string names "\n"))) | |
| 448 | |
| 449 (defun reftex-parse-bibtex-entry (entry &optional from to) | |
| 450 (let (alist key start field) | |
| 451 (save-excursion | |
| 452 (save-restriction | |
| 453 (if entry | |
| 454 (progn | |
| 455 (set-buffer (get-buffer-create " *RefTeX-scratch*")) | |
| 456 (fundamental-mode) | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
457 (set-syntax-table reftex-syntax-table-for-bib) |
| 25280 | 458 (erase-buffer) |
| 459 (insert entry)) | |
| 460 (widen) | |
| 461 (narrow-to-region from to)) | |
| 462 (goto-char (point-min)) | |
| 463 | |
| 464 (if (re-search-forward | |
| 465 "@\\(\\w+\\)[ \t\n\r]*[{(][ \t\n\r]*\\([^ \t\n\r,]+\\)" nil t) | |
| 466 (setq alist | |
| 467 (list | |
| 468 (cons "&type" (downcase (reftex-match-string 1))) | |
| 469 (cons "&key" (reftex-match-string 2))))) | |
| 470 (while (re-search-forward "\\(\\w+\\)[ \t\n\r]*=[ \t\n\r]*" nil t) | |
| 471 (setq key (downcase (reftex-match-string 1))) | |
| 472 (cond | |
| 473 ((= (following-char) ?{) | |
| 474 (forward-char 1) | |
| 475 (setq start (point)) | |
| 476 (condition-case nil | |
| 477 (up-list 1) | |
| 478 (error nil))) | |
| 479 ((= (following-char) ?\") | |
| 480 (forward-char 1) | |
| 481 (setq start (point)) | |
| 482 (while (and (search-forward "\"" nil t) | |
| 483 (= ?\\ (char-after (- (point) 2)))))) | |
| 484 (t | |
| 485 (setq start (point)) | |
| 486 (re-search-forward "[ \t]*[\n\r,}]" nil 1))) | |
| 487 (setq field (buffer-substring-no-properties start (1- (point)))) | |
| 488 ;; remove extra whitespace | |
| 489 (while (string-match "[\n\t\r]\\|[ \t][ \t]+" field) | |
| 490 (setq field (replace-match " " nil t field))) | |
| 491 ;; remove leading garbage | |
| 492 (if (string-match "^[ \t{]+" field) | |
| 493 (setq field (replace-match "" nil t field))) | |
| 494 ;; remove trailing garbage | |
| 495 (if (string-match "[ \t}]+$" field) | |
| 496 (setq field (replace-match "" nil t field))) | |
| 497 (push (cons key field) alist)))) | |
| 498 alist)) | |
| 499 | |
| 500 (defun reftex-get-bib-field (fieldname entry &optional format) | |
| 501 ;; Extract the field FIELDNAME from an ENTRY | |
| 502 (let ((cell (assoc fieldname entry))) | |
| 503 (if cell | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
504 (if format |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
505 (format format (cdr cell)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
506 (cdr cell)) |
| 25280 | 507 ""))) |
| 508 | |
| 509 (defun reftex-format-bib-entry (entry) | |
| 510 ;; Format a BibTeX ENTRY so that it is nice to look at | |
| 511 (let* | |
| 512 ((auth-list (reftex-get-bib-names "author" entry)) | |
| 513 (authors (mapconcat 'identity auth-list ", ")) | |
| 514 (year (reftex-get-bib-field "year" entry)) | |
| 515 (title (reftex-get-bib-field "title" entry)) | |
| 516 (type (reftex-get-bib-field "&type" entry)) | |
| 517 (key (reftex-get-bib-field "&key" entry)) | |
| 518 (extra | |
| 519 (cond | |
| 520 ((equal type "article") | |
| 521 (concat (reftex-get-bib-field "journal" entry) " " | |
| 522 (reftex-get-bib-field "volume" entry) ", " | |
| 523 (reftex-get-bib-field "pages" entry))) | |
| 524 ((equal type "book") | |
| 525 (concat "book (" (reftex-get-bib-field "publisher" entry) ")")) | |
| 526 ((equal type "phdthesis") | |
| 527 (concat "PhD: " (reftex-get-bib-field "school" entry))) | |
| 528 ((equal type "mastersthesis") | |
| 529 (concat "Master: " (reftex-get-bib-field "school" entry))) | |
| 530 ((equal type "inbook") | |
| 531 (concat "Chap: " (reftex-get-bib-field "chapter" entry) | |
| 532 ", pp. " (reftex-get-bib-field "pages" entry))) | |
| 533 ((or (equal type "conference") | |
| 534 (equal type "incollection") | |
| 535 (equal type "inproceedings")) | |
| 536 (reftex-get-bib-field "booktitle" entry "in: %s")) | |
| 537 (t "")))) | |
| 538 (setq authors (reftex-truncate authors 30 t t)) | |
| 539 (when (reftex-use-fonts) | |
| 540 (put-text-property 0 (length key) 'face | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
541 (reftex-verified-face reftex-label-face |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
542 'font-lock-constant-face |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
543 'font-lock-reference-face) |
| 25280 | 544 key) |
| 545 (put-text-property 0 (length authors) 'face reftex-bib-author-face | |
| 546 authors) | |
| 547 (put-text-property 0 (length year) 'face reftex-bib-year-face | |
| 548 year) | |
| 549 (put-text-property 0 (length title) 'face reftex-bib-title-face | |
| 550 title) | |
| 551 (put-text-property 0 (length extra) 'face reftex-bib-extra-face | |
| 552 extra)) | |
| 553 (concat key "\n " authors " " year " " extra "\n " title "\n\n"))) | |
| 554 | |
| 555 (defun reftex-parse-bibitem (item) | |
| 556 ;; Parse a \bibitem entry | |
| 557 (let ((key "") (text "")) | |
|
37998
706af946b1e7
* reftex-ref.el (reftex-select-label-help): Added "z" key
Carsten Dominik <dominik@science.uva.nl>
parents:
34402
diff
changeset
|
558 (when (string-match "\\`{\\([^}]+\\)}\\([^\000]*\\)" item) |
| 25280 | 559 (setq key (match-string 1 item) |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
560 text (match-string 2 item))) |
| 25280 | 561 ;; Clean up the text a little bit |
| 562 (while (string-match "[\n\r\t]\\|[ \t][ \t]+" text) | |
| 563 (setq text (replace-match " " nil t text))) | |
| 564 (if (string-match "\\`[ \t]+" text) | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
565 (setq text (replace-match "" nil t text))) |
| 25280 | 566 (list |
| 567 (cons "&key" key) | |
| 568 (cons "&text" text) | |
| 569 (cons "&entry" (concat key " " text))))) | |
| 570 | |
| 571 (defun reftex-format-bibitem (item) | |
| 572 ;; Format a \bibitem entry so that it is (relatively) nice to look at. | |
| 573 (let ((text (reftex-get-bib-field "&text" item)) | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
574 (key (reftex-get-bib-field "&key" item)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
575 (lines nil)) |
| 25280 | 576 |
| 577 ;; Wrap the text into several lines. | |
| 578 (while (and (> (length text) 70) | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
579 (string-match " " (substring text 60))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
580 (push (substring text 0 (+ 60 (match-beginning 0))) lines) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
581 (setq text (substring text (+ 61 (match-beginning 0))))) |
| 25280 | 582 (push text lines) |
| 583 (setq text (mapconcat 'identity (nreverse lines) "\n ")) | |
| 584 | |
| 585 (when (reftex-use-fonts) | |
| 586 (put-text-property 0 (length text) 'face reftex-bib-author-face text)) | |
| 587 (concat key "\n " text "\n\n"))) | |
| 588 | |
| 589 ;; Make a citation | |
| 590 | |
| 591 ;;;###autoload | |
|
26910
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25806
diff
changeset
|
592 (defun reftex-citation (&optional no-insert format-key) |
| 25280 | 593 "Make a citation using BibTeX database files. |
| 594 After prompting for a regular expression, scans the buffers with | |
| 595 bibtex entries (taken from the \\bibliography command) and offers the | |
|
46131
7255ef8cf60f
(reftex-citation): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
45318
diff
changeset
|
596 matching entries for selection. The selected entry is formatted according |
| 25280 | 597 to `reftex-cite-format' and inserted into the buffer. |
| 598 | |
| 599 If NO-INSERT is non-nil, nothing is inserted, only the selected key returned. | |
| 600 | |
|
59579
a588c86a429c
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-40
Miles Bader <miles@gnu.org>
parents:
59534
diff
changeset
|
601 FORMAT-KEY can be used to pre-select a citation format. |
|
26910
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25806
diff
changeset
|
602 |
|
59534
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
603 When called with a `C-u' prefix, prompt for optional arguments in |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
604 cite macros. When called with a numeric prefix, make that many |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
605 citations. When called with point inside the braces of a `\\cite' |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
606 command, it will add another key, ignoring the value of |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
607 `reftex-cite-format'. |
| 25280 | 608 |
| 609 The regular expression uses an expanded syntax: && is interpreted as `and'. | |
| 610 Thus, `aaaa&&bbb' matches entries which contain both `aaaa' and `bbb'. | |
| 611 While entering the regexp, completion on knows citation keys is possible. | |
| 612 `=' is a good regular expression to match all entries in all files." | |
| 613 | |
| 614 (interactive) | |
| 615 | |
| 616 ;; check for recursive edit | |
| 617 (reftex-check-recursive-edit) | |
| 618 | |
| 619 ;; This function may also be called outside reftex-mode. | |
| 620 ;; Thus look for the scanning info only if in reftex-mode. | |
| 621 | |
| 622 (when reftex-mode | |
|
59534
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
623 (reftex-access-scan-info nil)) |
| 25280 | 624 |
| 625 ;; Call reftex-do-citation, but protected | |
| 626 (unwind-protect | |
|
26910
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25806
diff
changeset
|
627 (reftex-do-citation current-prefix-arg no-insert format-key) |
| 25280 | 628 (reftex-kill-temporary-buffers))) |
| 629 | |
|
26910
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25806
diff
changeset
|
630 (defun reftex-do-citation (&optional arg no-insert format-key) |
| 25280 | 631 ;; This really does the work of reftex-citation. |
| 632 | |
|
26910
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25806
diff
changeset
|
633 (let* ((format (reftex-figure-out-cite-format arg no-insert format-key)) |
|
59534
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
634 (start 0) |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
635 (docstruct-symbol reftex-docstruct-symbol) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
636 (selected-entries (reftex-offer-bib-menu)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
637 (insert-entries selected-entries) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
638 entry string cite-view) |
| 25280 | 639 |
|
59534
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
640 (when (stringp selected-entries) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
641 (error selected-entries)) |
| 25280 | 642 (unless selected-entries (error "Quit")) |
| 643 | |
| 644 (if (stringp selected-entries) | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
645 ;; Nonexistent entry |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
646 (setq selected-entries nil |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
647 insert-entries (list (list selected-entries |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
648 (cons "&key" selected-entries)))) |
| 25280 | 649 ;; It makes sense to compute the cite-view strings. |
| 650 (setq cite-view t)) | |
| 651 | |
| 652 (when (eq (car selected-entries) 'concat) | |
| 653 ;; All keys go into a single command - we need to trick a little | |
|
59534
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
654 ;; FIXME: Unfortunately, this meens that commenting does not work right. |
| 25280 | 655 (pop selected-entries) |
| 656 (let ((concat-keys (mapconcat 'car selected-entries ","))) | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
657 (setq insert-entries |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
658 (list (list concat-keys (cons "&key" concat-keys)))))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
659 |
| 25280 | 660 (unless no-insert |
| 661 | |
| 662 ;; We shall insert this into the buffer... | |
| 663 (message "Formatting...") | |
|
59579
a588c86a429c
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-40
Miles Bader <miles@gnu.org>
parents:
59534
diff
changeset
|
664 |
| 25280 | 665 (while (setq entry (pop insert-entries)) |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
666 ;; Format the citation and insert it |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
667 (setq string (if reftex-format-cite-function |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
668 (funcall reftex-format-cite-function |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
669 (reftex-get-bib-field "&key" entry) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
670 format) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
671 (reftex-format-citation entry format))) |
|
59534
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
672 (when (or (eq reftex-cite-prompt-optional-args t) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
673 (and reftex-cite-prompt-optional-args |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
674 (equal arg '(4)))) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
675 (let ((start 0) (nth 0) value) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
676 (while (setq start (string-match "\\[\\]" string start)) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
677 (setq value (read-string (format "Optional argument %d: " |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
678 (setq nth (1+ nth))))) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
679 (setq string (replace-match (concat "[" value "]") t t string)) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
680 (setq start (1+ start))))) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
681 ;; Should we cleanup empty optional arguments? |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
682 ;; if the first is empty, it can be removed. If the second is empty, |
|
60056
978d83f0a49f
(reftex-do-citation): Cleanup single
Carsten Dominik <dominik@science.uva.nl>
parents:
59579
diff
changeset
|
683 ;; it has to go. If there is only a single arg and empty, it can go |
|
62467
35f6599373fc
* textmodes/reftex-vars.el (reftex-cite-format-builtin): Support
Carsten Dominik <dominik@science.uva.nl>
parents:
62402
diff
changeset
|
684 ;; as well. |
|
59534
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
685 (when reftex-cite-cleanup-optional-args |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
686 (cond |
|
60056
978d83f0a49f
(reftex-do-citation): Cleanup single
Carsten Dominik <dominik@science.uva.nl>
parents:
59579
diff
changeset
|
687 ((string-match "\\([a-zA-Z0-9]\\)\\[\\]{" string) |
|
978d83f0a49f
(reftex-do-citation): Cleanup single
Carsten Dominik <dominik@science.uva.nl>
parents:
59579
diff
changeset
|
688 (setq string (replace-match "\\1{" nil nil string))) |
|
59534
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
689 ((string-match "\\[\\]\\(\\[[a-zA-Z0-9., ]+\\]\\)" string) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
690 (setq string (replace-match "\\1" nil nil string))) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
691 ((string-match "\\[\\]\\[\\]" string) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
692 (setq string (replace-match "" t t string))))) |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
693 (insert string)) |
| 25280 | 694 |
| 695 ;; Reposition cursor? | |
| 696 (when (string-match "\\?" string) | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
697 (search-backward "?") |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
698 (delete-char 1)) |
| 25280 | 699 |
| 700 ;; Tell AUCTeX | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
701 (when (and reftex-mode |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
702 (fboundp 'LaTeX-add-bibitems) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
703 reftex-plug-into-AUCTeX) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
704 (apply 'LaTeX-add-bibitems (mapcar 'car selected-entries))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
705 |
| 25280 | 706 ;; Produce the cite-view strings |
| 707 (when (and reftex-mode reftex-cache-cite-echo cite-view) | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
708 (mapcar (lambda (entry) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
709 (reftex-make-cite-echo-string entry docstruct-symbol)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
710 selected-entries)) |
| 25280 | 711 |
| 712 (message "")) | |
| 713 | |
| 714 (set-marker reftex-select-return-marker nil) | |
| 715 (reftex-kill-buffer "*RefTeX Select*") | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
716 |
| 25280 | 717 ;; Check if the prefix arg was numeric, and call recursively |
| 718 (when (integerp arg) | |
| 719 (if (> arg 1) | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
720 (progn |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
721 (skip-chars-backward "}") |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
722 (decf arg) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
723 (reftex-do-citation arg)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
724 (forward-char 1))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
725 |
| 25280 | 726 ;; Return the citation key |
| 727 (car (car selected-entries)))) | |
| 728 | |
|
26910
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25806
diff
changeset
|
729 (defun reftex-figure-out-cite-format (arg &optional no-insert format-key) |
| 25280 | 730 ;; Check if there is already a cite command at point and change cite format |
| 731 ;; in order to only add another reference in the same cite command. | |
| 732 (let ((macro (car (reftex-what-macro 1))) | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
733 (cite-format-value (reftex-get-cite-format)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
734 key format) |
| 25280 | 735 (cond |
| 736 (no-insert | |
| 737 ;; Format does not really matter because nothing will be inserted. | |
| 738 (setq format "%l")) | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
739 |
| 25280 | 740 ((and (stringp macro) |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
741 (string-match "\\`\\\\cite\\|cite\\'" macro)) |
| 25280 | 742 ;; We are already inside a cite macro |
| 743 (if (or (not arg) (not (listp arg))) | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
744 (setq format |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
745 (concat |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
746 (if (member (preceding-char) '(?\{ ?,)) "" ",") |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
747 "%l" |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
748 (if (member (following-char) '(?\} ?,)) "" ","))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
749 (setq format "%l"))) |
| 25280 | 750 (t |
| 751 ;; Figure out the correct format | |
| 752 (setq format | |
| 753 (if (and (symbolp cite-format-value) | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
754 (assq cite-format-value reftex-cite-format-builtin)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
755 (nth 2 (assq cite-format-value reftex-cite-format-builtin)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
756 cite-format-value)) |
| 25280 | 757 (when (listp format) |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
758 (setq key |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
759 (or format-key |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
760 (reftex-select-with-char |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
761 "" (concat "SELECT A CITATION FORMAT\n\n" |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
762 (mapconcat |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
763 (lambda (x) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
764 (format "[%c] %s %s" (car x) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
765 (if (> (car x) 31) " " "") |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
766 (cdr x))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
767 format "\n"))))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
768 (if (assq key format) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
769 (setq format (cdr (assq key format))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
770 (error "No citation format associated with key `%c'" key))))) |
| 25280 | 771 format)) |
| 772 | |
|
26910
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25806
diff
changeset
|
773 (defun reftex-citep () |
|
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25806
diff
changeset
|
774 "Call `reftex-citation' with a format selector `?p'." |
|
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25806
diff
changeset
|
775 (interactive) |
|
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25806
diff
changeset
|
776 (reftex-citation nil ?p)) |
|
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25806
diff
changeset
|
777 |
|
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25806
diff
changeset
|
778 (defun reftex-citet () |
|
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25806
diff
changeset
|
779 "Call `reftex-citation' with a format selector `?t'." |
|
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25806
diff
changeset
|
780 (interactive) |
|
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25806
diff
changeset
|
781 (reftex-citation nil ?t)) |
|
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25806
diff
changeset
|
782 |
| 25280 | 783 (defvar reftex-select-bib-map) |
| 784 (defun reftex-offer-bib-menu () | |
| 785 ;; Offer bib menu and return list of selected items | |
| 786 | |
|
46973
11e08f9901ea
Update to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
787 (let ((bibtype (reftex-bib-or-thebib)) |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
788 found-list rtn key data selected-entries) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
789 (while |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
790 (not |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
791 (catch 'done |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
792 ;; Scan bibtex files |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
793 (setq found-list |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
794 (cond |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
795 ((eq bibtype 'bib) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
796 ; ((assq 'bib (symbol-value reftex-docstruct-symbol)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
797 ;; using BibTeX database files. |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
798 (reftex-extract-bib-entries (reftex-get-bibfile-list))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
799 ((eq bibtype 'thebib) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
800 ; ((assq 'thebib (symbol-value reftex-docstruct-symbol)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
801 ;; using thebibliography environment. |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
802 (reftex-extract-bib-entries-from-thebibliography |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
803 (reftex-uniquify |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
804 (mapcar 'cdr |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
805 (reftex-all-assq |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
806 'thebib (symbol-value reftex-docstruct-symbol)))))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
807 (reftex-default-bibliography |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
808 (message "Using default bibliography") |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
809 (reftex-extract-bib-entries (reftex-default-bibliography))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
810 (t (error "No valid bibliography in this document, and no default available")))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
811 |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
812 (unless found-list |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
813 (error "Sorry, no matches found")) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
814 |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
815 ;; Remember where we came from |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
816 (setq reftex-call-back-to-this-buffer (current-buffer)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
817 (set-marker reftex-select-return-marker (point)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
818 |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
819 ;; Offer selection |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
820 (save-window-excursion |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
821 (delete-other-windows) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
822 (let ((default-major-mode 'reftex-select-bib-mode)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
823 (reftex-kill-buffer "*RefTeX Select*") |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
824 (switch-to-buffer-other-window "*RefTeX Select*") |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
825 (unless (eq major-mode 'reftex-select-bib-mode) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
826 (reftex-select-bib-mode)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
827 (let ((buffer-read-only nil)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
828 (erase-buffer) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
829 (reftex-insert-bib-matches found-list))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
830 (setq buffer-read-only t) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
831 (if (= 0 (buffer-size)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
832 (error "No matches found")) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
833 (setq truncate-lines t) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
834 (goto-char 1) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
835 (while t |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
836 (setq rtn |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
837 (reftex-select-item |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
838 reftex-citation-prompt |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
839 reftex-citation-help |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
840 reftex-select-bib-map |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
841 nil |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
842 'reftex-bibtex-selection-callback nil)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
843 (setq key (car rtn) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
844 data (nth 1 rtn)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
845 (unless key (throw 'done t)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
846 (cond |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
847 ((eq key ?g) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
848 ;; Start over |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
849 (throw 'done nil)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
850 ((eq key ?r) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
851 ;; Restrict with new regular expression |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
852 (setq found-list (reftex-restrict-bib-matches found-list)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
853 (let ((buffer-read-only nil)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
854 (erase-buffer) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
855 (reftex-insert-bib-matches found-list)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
856 (goto-char 1)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
857 ((eq key ?A) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
858 ;; Take all (marked) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
859 (setq selected-entries |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
860 (if reftex-select-marked |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
861 (mapcar 'car (nreverse reftex-select-marked)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
862 found-list)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
863 (throw 'done t)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
864 ((eq key ?a) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
865 ;; Take all (marked), and push the symbol 'concat |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
866 (setq selected-entries |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
867 (cons 'concat |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
868 (if reftex-select-marked |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
869 (mapcar 'car (nreverse reftex-select-marked)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
870 found-list))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
871 (throw 'done t)) |
|
59534
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
872 ((eq key ?e) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
873 ;; Take all (marked), and push the symbol 'concat |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
874 (reftex-extract-bib-file found-list reftex-select-marked) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
875 (setq selected-entries "BibTeX database file created") |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
876 (throw 'done t)) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
877 ((eq key ?E) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
878 ;; Take all (marked), and push the symbol 'concat |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
879 (reftex-extract-bib-file found-list reftex-select-marked |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
880 'complement) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
881 (setq selected-entries "BibTeX database file created") |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
882 (throw 'done t)) |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
883 ((or (eq key ?\C-m) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
884 (eq key 'return)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
885 ;; Take selected |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
886 (setq selected-entries |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
887 (if reftex-select-marked |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
888 (cons 'concat |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
889 (mapcar 'car (nreverse reftex-select-marked))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
890 (if data (list data) nil))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
891 (throw 'done t)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
892 ((stringp key) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
893 ;; Got this one with completion |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
894 (setq selected-entries key) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
895 (throw 'done t)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
896 (t |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
897 (ding)))))))) |
| 25280 | 898 selected-entries)) |
| 899 | |
| 900 (defun reftex-restrict-bib-matches (found-list) | |
| 901 ;; Limit FOUND-LIST with more regular expressions | |
| 902 (let ((re-list (split-string (read-string | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
903 "RegExp [ && RegExp...]: " |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
904 nil 'reftex-cite-regexp-hist) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
905 "[ \t]*&&[ \t]*")) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
906 (found-list-r found-list) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
907 re) |
| 25280 | 908 (while (setq re (pop re-list)) |
| 909 (setq found-list-r | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
910 (delq nil |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
911 (mapcar |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
912 (lambda (x) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
913 (if (string-match |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
914 re (cdr (assoc "&entry" x))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
915 x |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
916 nil)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
917 found-list-r)))) |
| 25280 | 918 (if found-list-r |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
919 found-list-r |
| 25280 | 920 (ding) |
| 921 found-list))) | |
| 922 | |
|
59534
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
923 (defun reftex-extract-bib-file (all &optional marked complement) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
924 ;; Limit FOUND-LIST with more regular expressions |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
925 (let ((file (read-file-name "File to create: "))) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
926 (find-file-other-window file) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
927 (if (> (buffer-size) 0) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
928 (unless (yes-or-no-p |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
929 (format "Overwrite non-empty file %s? " file)) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
930 (error "Abort"))) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
931 (erase-buffer) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
932 (setq all (delq nil |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
933 (mapcar |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
934 (lambda (x) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
935 (if marked |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
936 (if (or (and (assoc x marked) (not complement)) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
937 (and (not (assoc x marked)) complement)) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
938 (cdr (assoc "&entry" x)) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
939 nil) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
940 (cdr (assoc "&entry" x)))) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
941 all))) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
942 (insert (mapconcat 'identity all "\n\n")) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
943 (save-buffer) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
944 (goto-char (point-min)))) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
945 |
| 25280 | 946 (defun reftex-insert-bib-matches (list) |
| 947 ;; Insert the bib matches and number them correctly | |
| 948 (let ((mouse-face | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
949 (if (memq reftex-highlight-selection '(mouse both)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
950 reftex-mouse-selected-face |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
951 nil)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
952 tmp len) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
953 (mapcar |
| 25280 | 954 (lambda (x) |
| 955 (setq tmp (cdr (assoc "&formatted" x)) | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
956 len (length tmp)) |
| 25280 | 957 (put-text-property 0 len :data x tmp) |
| 958 (put-text-property 0 (1- len) 'mouse-face mouse-face tmp) | |
| 959 (insert tmp)) | |
| 960 list)) | |
| 961 (run-hooks 'reftex-display-copied-context-hook)) | |
| 962 | |
| 963 (defun reftex-format-names (namelist n) | |
| 964 (let (last (len (length namelist))) | |
|
46612
7522419c4db0
Updated to reftex 4.17
Carsten Dominik <dominik@science.uva.nl>
parents:
46131
diff
changeset
|
965 (if (= n 0) (setq n len)) |
| 25280 | 966 (cond |
| 967 ((< len 1) "") | |
| 968 ((= 1 len) (car namelist)) | |
| 969 ((> len n) (concat (car namelist) (nth 2 reftex-cite-punctuation))) | |
| 970 (t | |
| 971 (setq n (min len n) | |
| 972 last (nth (1- n) namelist)) | |
| 973 (setcdr (nthcdr (- n 2) namelist) nil) | |
| 974 (concat | |
| 975 (mapconcat 'identity namelist (nth 0 reftex-cite-punctuation)) | |
| 976 (nth 1 reftex-cite-punctuation) | |
| 977 last))))) | |
| 978 | |
| 979 (defun reftex-format-citation (entry format) | |
| 980 ;; Format a citation from the info in the BibTeX ENTRY | |
| 981 | |
| 982 (unless (stringp format) (setq format "\\cite{%l}")) | |
| 983 | |
| 984 (if (and reftex-comment-citations | |
| 985 (string-match "%l" reftex-cite-comment-format)) | |
|
60918
58a53f588384
* textmodes/refbib.el, textmodes/refer.el, textmodes/reftex-cite.el,
Werner LEMBERG <wl@gnu.org>
parents:
60056
diff
changeset
|
986 (error "reftex-cite-comment-format contains invalid %%l")) |
| 25280 | 987 |
| 988 (while (string-match | |
| 989 "\\(\\`\\|[^%]\\)\\(\\(%\\([0-9]*\\)\\([a-zA-Z]\\)\\)[.,;: ]*\\)" | |
| 990 format) | |
|
62402
a7e02ef1e3d6
Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents:
60918
diff
changeset
|
991 (let ((n (string-to-number (match-string 4 format))) |
| 25280 | 992 (l (string-to-char (match-string 5 format))) |
| 993 rpl b e) | |
| 994 (save-match-data | |
| 995 (setq rpl | |
| 996 (cond | |
| 997 ((= l ?l) (concat | |
| 998 (reftex-get-bib-field "&key" entry) | |
| 999 (if reftex-comment-citations | |
| 1000 reftex-cite-comment-format | |
| 1001 ""))) | |
| 1002 ((= l ?a) (reftex-format-names | |
| 1003 (reftex-get-bib-names "author" entry) | |
| 1004 (or n 2))) | |
| 1005 ((= l ?A) (car (reftex-get-bib-names "author" entry))) | |
| 1006 ((= l ?b) (reftex-get-bib-field "booktitle" entry "in: %s")) | |
| 1007 ((= l ?B) (reftex-abbreviate-title | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1008 (reftex-get-bib-field "booktitle" entry "in: %s"))) |
| 25280 | 1009 ((= l ?c) (reftex-get-bib-field "chapter" entry)) |
| 1010 ((= l ?d) (reftex-get-bib-field "edition" entry)) | |
| 1011 ((= l ?e) (reftex-format-names | |
| 1012 (reftex-get-bib-names "editor" entry) | |
| 1013 (or n 2))) | |
| 1014 ((= l ?E) (car (reftex-get-bib-names "editor" entry))) | |
| 1015 ((= l ?h) (reftex-get-bib-field "howpublished" entry)) | |
| 1016 ((= l ?i) (reftex-get-bib-field "institution" entry)) | |
| 1017 ((= l ?j) (reftex-get-bib-field "journal" entry)) | |
| 1018 ((= l ?k) (reftex-get-bib-field "key" entry)) | |
| 1019 ((= l ?m) (reftex-get-bib-field "month" entry)) | |
| 1020 ((= l ?n) (reftex-get-bib-field "number" entry)) | |
| 1021 ((= l ?o) (reftex-get-bib-field "organization" entry)) | |
| 1022 ((= l ?p) (reftex-get-bib-field "pages" entry)) | |
| 1023 ((= l ?P) (car (split-string | |
| 1024 (reftex-get-bib-field "pages" entry) | |
| 1025 "[- .]+"))) | |
| 1026 ((= l ?s) (reftex-get-bib-field "school" entry)) | |
| 1027 ((= l ?u) (reftex-get-bib-field "publisher" entry)) | |
| 1028 ((= l ?r) (reftex-get-bib-field "address" entry)) | |
| 1029 ((= l ?t) (reftex-get-bib-field "title" entry)) | |
| 1030 ((= l ?T) (reftex-abbreviate-title | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1031 (reftex-get-bib-field "title" entry))) |
| 25280 | 1032 ((= l ?v) (reftex-get-bib-field "volume" entry)) |
| 1033 ((= l ?y) (reftex-get-bib-field "year" entry))))) | |
| 1034 | |
| 1035 (if (string= rpl "") | |
| 1036 (setq b (match-beginning 2) e (match-end 2)) | |
| 1037 (setq b (match-beginning 3) e (match-end 3))) | |
| 1038 (setq format (concat (substring format 0 b) rpl (substring format e))))) | |
| 1039 (while (string-match "%%" format) | |
| 1040 (setq format (replace-match "%" t t format))) | |
| 1041 (while (string-match "[ ,.;:]*%<" format) | |
| 1042 (setq format (replace-match "" t t format))) | |
| 1043 format) | |
| 1044 | |
| 1045 (defun reftex-make-cite-echo-string (entry docstruct-symbol) | |
| 1046 ;; Format a bibtex entry for the echo area and cache the result. | |
| 1047 (let* ((key (reftex-get-bib-field "&key" entry)) | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1048 (string |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1049 (let* ((reftex-cite-punctuation '(" " " & " " etal."))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1050 (reftex-format-citation entry reftex-cite-view-format))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1051 (cache (assq 'bibview-cache (symbol-value docstruct-symbol))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1052 (cache-entry (assoc key (cdr cache)))) |
| 25280 | 1053 (unless cache |
| 1054 ;; This docstruct has no cache - make one. | |
| 1055 (set docstruct-symbol (cons (cons 'bibview-cache nil) | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1056 (symbol-value docstruct-symbol)))) |
| 25280 | 1057 (when reftex-cache-cite-echo |
| 1058 (setq key (copy-sequence key)) | |
| 1059 (set-text-properties 0 (length key) nil key) | |
| 1060 (set-text-properties 0 (length string) nil string) | |
| 1061 (if cache-entry | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1062 (unless (string= (cdr cache-entry) string) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1063 (setcdr cache-entry string) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1064 (put reftex-docstruct-symbol 'modified t)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1065 (push (cons key string) (cdr cache)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1066 (put reftex-docstruct-symbol 'modified t))) |
| 25280 | 1067 string)) |
| 1068 | |
| 1069 (defun reftex-bibtex-selection-callback (data ignore no-revisit) | |
| 1070 ;; Callback function to be called from the BibTeX selection, in | |
| 1071 ;; order to display context. This function is relatively slow and not | |
| 1072 ;; recommended for follow mode. It works OK for individual lookups. | |
| 1073 (let ((win (selected-window)) | |
| 1074 (key (reftex-get-bib-field "&key" data)) | |
|
46973
11e08f9901ea
Update to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
1075 bibfile-list item bibtype) |
| 25280 | 1076 |
| 1077 (catch 'exit | |
| 1078 (save-excursion | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1079 (set-buffer reftex-call-back-to-this-buffer) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1080 (setq bibtype (reftex-bib-or-thebib)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1081 (cond |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1082 ((eq bibtype 'bib) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1083 ; ((assq 'bib (symbol-value reftex-docstruct-symbol)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1084 (setq bibfile-list (reftex-get-bibfile-list))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1085 ((eq bibtype 'thebib) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1086 ; ((assq 'thebib (symbol-value reftex-docstruct-symbol)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1087 (setq bibfile-list |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1088 (reftex-uniquify |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1089 (mapcar 'cdr |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1090 (reftex-all-assq |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1091 'thebib (symbol-value reftex-docstruct-symbol)))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1092 item t)) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1093 (reftex-default-bibliography |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1094 (setq bibfile-list (reftex-default-bibliography))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1095 (t (ding) (throw 'exit nil)))) |
| 25280 | 1096 |
| 1097 (when no-revisit | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1098 (setq bibfile-list (reftex-visited-files bibfile-list))) |
| 25280 | 1099 |
| 1100 (condition-case nil | |
|
52170
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1101 (reftex-pop-to-bibtex-entry |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1102 key bibfile-list (not reftex-keep-temporary-buffers) t item) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1103 (error (ding)))) |
|
27340819ef07
Updated to version 4.21
Carsten Dominik <dominik@science.uva.nl>
parents:
50976
diff
changeset
|
1104 |
| 25280 | 1105 (select-window win))) |
| 1106 | |
|
59534
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1107 ;;; Global BibTeX file |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1108 (defun reftex-all-used-citation-keys () |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1109 (reftex-access-scan-info) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1110 (let ((files (reftex-all-document-files)) file keys kkk kk k) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1111 (save-excursion |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1112 (while (setq file (pop files)) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1113 (set-buffer (reftex-get-file-buffer-force file 'mark)) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1114 (save-excursion |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1115 (save-restriction |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1116 (widen) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1117 (goto-char (point-min)) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1118 (while (re-search-forward "^[^%\n\r]*\\\\\\(bibentry\\|[a-zA-Z]*cite[a-zA-Z]*\\)\\(\\[[^\\]]*\\]\\)?{\\([^}]+\\)}" nil t) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1119 (setq kk (match-string-no-properties 3)) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1120 (while (string-match "%.*\n?" kk) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1121 (setq kk (replace-match "" t t kk))) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1122 (setq kk (split-string kk "[, \t\r\n]+")) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1123 (while (setq k (pop kk)) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1124 (or (member k keys) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1125 (setq keys (cons k keys))))))))) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1126 (reftex-kill-temporary-buffers) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1127 keys)) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1128 |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1129 (defun reftex-create-bibtex-file (bibfile) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1130 "Create a new BibTeX database file with all entries referenced in document. |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1131 The command prompts for a filename and writes the collected entries to |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1132 that file. Only entries referenced in the current document with |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1133 any \\cite-like macros are used. |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1134 The sequence in the new file is the same as it was in the old database." |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1135 (interactive "FNew BibTeX file: ") |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1136 (let ((keys (reftex-all-used-citation-keys)) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1137 (files (reftex-get-bibfile-list)) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1138 file key entries beg end entry) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1139 (save-excursion |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1140 (while (setq file (pop files)) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1141 (set-buffer (reftex-get-file-buffer-force file 'mark)) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1142 (reftex-with-special-syntax-for-bib |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1143 (save-excursion |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1144 (save-restriction |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1145 (widen) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1146 (goto-char (point-min)) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1147 (while (re-search-forward |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1148 "^[ \t]*@[a-zA-Z]+[ \t]*{\\([^ \t\r\n]+\\)," |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1149 nil t) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1150 (setq key (match-string 1) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1151 beg (match-beginning 0) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1152 end (progn |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1153 (goto-char (match-beginning 1)) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1154 (condition-case nil |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1155 (up-list 1) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1156 (error (goto-char (match-end 0)))) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1157 (point))) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1158 (when (member key keys) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1159 (setq entry (buffer-substring beg end) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1160 entries (cons entry entries) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1161 keys (delete key keys))))))))) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1162 (find-file-other-window bibfile) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1163 (if (> (buffer-size) 0) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1164 (unless (yes-or-no-p |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1165 (format "Overwrite non-empty file %s? " bibfile)) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1166 (error "Abort"))) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1167 (erase-buffer) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1168 (insert (mapconcat 'identity (reverse entries) "\n\n")) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1169 (goto-char (point-min)) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1170 (save-buffer) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1171 (message "%d entries extracted and copied to new database" |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1172 (length entries)))) |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1173 |
|
9bad65481674
2005-01-14 Carsten Dominik <dominik@science.uva.nl>
Carsten Dominik <dominik@science.uva.nl>
parents:
59373
diff
changeset
|
1174 |
| 52401 | 1175 ;;; arch-tag: d53d0a5a-ab32-4b52-a846-2a7c3527cd89 |
| 25280 | 1176 ;;; reftex-cite.el ends here |
