Mercurial > emacs
annotate lisp/textmodes/reftex-vcr.el @ 26910:489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
`reftex-index-macro'
(reftex-compile-variables): Use the changed structure of
`reftex-label-alist'.
* reftex-vars.el (reftex-index-math-format,
(reftex-toc-max-level): New option.
reftex-index-phrases-search-whole-words,
reftex-index-phrases-case-fold-search,
reftex-index-phrases-skip-indexed-matches,
reftex-index-phrases-wrap-long-lines,
reftex-index-phrases-sort-prefers-entry,
reftex-index-phrases-sort-in-blocks): New options.
(reftex-index-macros): Option structure changed.
(reftex-index-macros-builtin): Added `repeat' item to each entry.
(reftex-label-alist): Additional item in each entry to specify if
the environment should be listed in the TOC.
(eval-when-compile (require 'cl)) added.
* reftex-index.el (reftex-index-selection-or-word): No longer
deals with "repeat".
(reftex-index): "repeat property in `reftex-index-macro-alist' is
now used.
(reftex-index-phrases-comment-regexp,
reftex-index-phrases-macrodef-regexp,
reftex-index-phrases-phrase-regexp1,
reftex-index-phrases-phrase-regexp2,
reftex-index-phrases-phrase-regexp12, reftex-index-phrases-help):
New constants.
(reftex-index-phrases-macro-data, reftex-index-phrases-files,
reftex-index-phrases-font-lock-keywords,
reftex-index-phrases-font-lock-defaults, reftex-index-phrases-map,
reftex-index-phrases-restrict-file): New variables.
(reftex-index-phrase-selection-or-word,
reftex-index-visit-phrases-buffer,
reftex-index-initialize-phrases-buffer,
reftex-index-phrases-save-and-return, reftex-index-phrases-mode,
reftex-index-next-phrase, reftex-index-this-phrase,
reftex-index-all-phrases, reftex-index-region-phrases,
reftex-index-phrases-parse-header,
reftex-index-phrases-toggle-restricted, reftex-index-new-phrase,
reftex-index-find-next-conflict-phrase, reftex-index-phrases-info,
reftex-index-phrases-set-macro-key, reftex-index-sort-phrases,
reftex-compare-phrase-lines, reftex-index-make-phrase-regexp,
reftex-index-simplify-phrase, reftex-index-phrases-find-dup-re,
reftex-index-make-replace-string,
reftex-query-index-phrase-globally, reftex-query-index-phrase,
reftex-index-phrase-match-is-indexed,
reftex-index-phrases-fixup-line,
reftex-index-phrases-replace-space,
reftex-index-select-phrases-macro): New functions.
(reftex-index-globalize, reftex-index-globally): functions removed
(eval-when-compile (require 'cl)) added.
* reftex-toc.el (reftex-toc-mode): Create new indicator for max
level.
(reftex-toc-max-level-indicator): New variable.
(reftex-toc-max-level): New command.
(reftex-toc-map): New keybinding `t'.
(reftex-toc-help): Constant updated.
(eval-when-compile (require 'cl)) added.
* reftex-ref.el (reftex-offer-label-menu): Prefix to `t' command key
can change `reftex-toc-max-level'
(eval-when-compile (require 'cl)) added.
* reftex-sel (reftex-insert-docstruct): Respect
`reftex-toc-max-level'
(eval-when-compile (require 'cl)) added.
* reftex-auc.el (eval-when-compile (require 'cl)) added.
* reftex-vcr.el (eval-when-compile (require 'cl)) added.
* reftex-cite.el (reftex-citep, reftex-citet): New commands.
(reftex-citation, reftex-do-citation,
reftex-figure-out-cite-format): Additional argument FORMAT-KEY to
preselect a citation format.
(eval-when-compile (require 'cl)) added.
* reftex-parse.el (reftex-context-substring): Optional parameter
to-end
(reftex-section-info): Deal with environment matches.
(eval-when-compile (require 'cl)) added.
* reftex-global.el (eval-when-compile (require 'cl)) added.
author | Carsten Dominik <dominik@science.uva.nl> |
---|---|
date | Wed, 15 Dec 1999 17:02:38 +0000 |
parents | efe07431a7ba |
children | 083669ed376a |
rev | line source |
---|---|
25280 | 1 ;;; reftex-vcr.el - Viewing cross references and citations with RefTeX |
26910
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25805
diff
changeset
|
2 ;;; Version: 4.9 |
25280 | 3 ;;; |
4 ;;; See main file reftex.el for licensing information | |
5 | |
26910
489a5439b988
* reftex.el (reftex-compile-variables): respect new structure of
Carsten Dominik <dominik@science.uva.nl>
parents:
25805
diff
changeset
|
6 (eval-when-compile (require 'cl)) |
25280 | 7 (provide 'reftex-vcr) |
8 (require 'reftex) | |
9 ;;; | |
10 | |
11 (defun reftex-view-crossref (&optional arg auto-how) | |
12 "View cross reference of macro at point. Point must be on the KEY | |
13 argument. When at at `\ref' macro, show corresponding `\label' | |
14 definition, also in external documents (`xr'). When on a label, show | |
15 a locations where KEY is referenced. Subsequent calls find additional | |
16 locations. When on a `\cite', show the associated `\bibitem' macro or | |
17 the BibTeX database entry. When on a `\bibitem', show a `\cite' macro | |
18 which uses this KEY. When on an `\index', show other locations marked | |
19 by the same index entry. | |
20 To define additional cross referencing items, use the option | |
21 `reftex-view-crossref-extra'. See also `reftex-view-crossref-from-bibtex'. | |
22 With one or two C-u prefixes, enforce rescanning of the document. | |
23 With argument 2, select the window showing the cross reference. | |
24 AUTO-HOW is only for the automatic crossref display and is handed through | |
25 to the functions `reftex-view-cr-cite' and `reftex-view-cr-ref'." | |
26 | |
27 (interactive "P") | |
28 ;; See where we are. | |
29 (let* ((macro (car (reftex-what-macro-safe 1))) | |
30 (key (reftex-this-word "^{}%\n\r,")) | |
31 dw) | |
32 | |
33 (if (or (null macro) (reftex-in-comment)) | |
34 (error "Not on a crossref macro argument")) | |
35 | |
36 (setq reftex-call-back-to-this-buffer (current-buffer)) | |
37 | |
38 (cond | |
39 ((string-match "\\`\\\\cite\\|cite\\*?\\'" macro) | |
40 ;; A citation macro: search for bibitems or BibTeX entries | |
41 (setq dw (reftex-view-cr-cite arg key auto-how))) | |
42 ((string-match "\\`\\\\ref\\|ref\\(range\\)?\\*?\\'" macro) | |
43 ;; A reference macro: search for labels | |
44 (setq dw (reftex-view-cr-ref arg key auto-how))) | |
45 (auto-how nil) ;; No further action for automatic display (speed) | |
46 ((or (equal macro "\\label") | |
47 (member macro reftex-macros-with-labels)) | |
48 ;; A label macro: search for reference macros | |
49 (reftex-access-scan-info arg) | |
50 (setq dw (reftex-view-regexp-match | |
51 (format reftex-find-reference-format (regexp-quote key)) | |
52 4 nil nil))) | |
53 ((equal macro "\\bibitem") | |
54 ;; A bibitem macro: search for citations | |
55 (reftex-access-scan-info arg) | |
56 (setq dw (reftex-view-regexp-match | |
57 (format reftex-find-citation-regexp-format (regexp-quote key)) | |
58 3 nil nil))) | |
59 ((member macro reftex-macros-with-index) | |
60 (reftex-access-scan-info arg) | |
61 (setq dw (reftex-view-regexp-match | |
62 (format reftex-find-index-entry-regexp-format | |
63 (regexp-quote key)) | |
64 3 nil nil))) | |
65 (t | |
66 (reftex-access-scan-info arg) | |
67 (catch 'exit | |
68 (let ((list reftex-view-crossref-extra) | |
69 entry mre action group) | |
70 (while (setq entry (pop list)) | |
71 (setq mre (car entry) | |
72 action (nth 1 entry) | |
73 group (nth 2 entry)) | |
74 (when (string-match mre macro) | |
75 (setq dw (reftex-view-regexp-match | |
76 (format action key) group nil nil)) | |
77 (throw 'exit t)))) | |
78 (error "Not on a crossref macro argument")))) | |
79 (if (and (eq arg 2) (windowp dw)) (select-window dw)))) | |
80 | |
81 (defun reftex-view-cr-cite (arg key how) | |
82 ;; View crossreference of a ref cite. HOW can have the values | |
83 ;; nil: Show in another window. | |
84 ;; echo: Show one-line info in echo area. | |
85 ;; tmp-window: Show in small window and arrange for window to disappear. | |
86 | |
87 ;; Ensure access to scanning info | |
88 (reftex-access-scan-info (or arg current-prefix-arg)) | |
89 | |
90 (if (eq how 'tmp-window) | |
91 ;; Remember the window configuration | |
92 (put 'reftex-auto-view-crossref 'last-window-conf | |
93 (current-window-configuration))) | |
94 | |
95 (let (files size item (pos (point)) (win (selected-window)) pop-win) | |
96 ;; Find the citation mode and the file list | |
97 (cond | |
98 ((assq 'bib (symbol-value reftex-docstruct-symbol)) | |
99 (setq item nil | |
100 files (reftex-get-bibfile-list))) | |
101 ((assq 'thebib (symbol-value reftex-docstruct-symbol)) | |
102 (setq item t | |
25805
efe07431a7ba
(reftex-view-cr-cite): Deal with multiple thebibliography environments.
Carsten Dominik <dominik@science.uva.nl>
parents:
25280
diff
changeset
|
103 files (reftex-uniquify |
efe07431a7ba
(reftex-view-cr-cite): Deal with multiple thebibliography environments.
Carsten Dominik <dominik@science.uva.nl>
parents:
25280
diff
changeset
|
104 (mapcar 'cdr |
efe07431a7ba
(reftex-view-cr-cite): Deal with multiple thebibliography environments.
Carsten Dominik <dominik@science.uva.nl>
parents:
25280
diff
changeset
|
105 (reftex-all-assq |
efe07431a7ba
(reftex-view-cr-cite): Deal with multiple thebibliography environments.
Carsten Dominik <dominik@science.uva.nl>
parents:
25280
diff
changeset
|
106 'thebib (symbol-value reftex-docstruct-symbol)))))) |
25280 | 107 (reftex-default-bibliography |
108 (setq item nil | |
109 files (reftex-default-bibliography))) | |
110 (how) ;; don't throw for special display | |
111 (t (error "Cannot display crossref"))) | |
112 | |
113 (if (eq how 'echo) | |
114 ;; Display in Echo area | |
115 (reftex-echo-cite key files item) | |
116 ;; Display in a window | |
117 (if (not (eq how 'tmp-window)) | |
118 ;; Normal display | |
119 (reftex-pop-to-bibtex-entry key files nil t item) | |
120 ;; A temporary window | |
121 (condition-case nil | |
122 (reftex-pop-to-bibtex-entry key files nil t item) | |
123 (error (goto-char pos) | |
124 (message "cite: no such citation key %s" key) | |
125 (error ""))) | |
126 ;; Resize the window | |
127 (setq size (max 1 (count-lines (point) | |
128 (reftex-end-of-bib-entry item)))) | |
129 (let ((window-min-height 2)) | |
130 (shrink-window (1- (- (window-height) size))) | |
131 (recenter 0)) | |
132 ;; Arrange restoration | |
133 (add-hook 'pre-command-hook 'reftex-restore-window-conf)) | |
134 | |
135 ;; Normal display in other window | |
136 (add-hook 'pre-command-hook 'reftex-highlight-shall-die) | |
137 (setq pop-win (selected-window)) | |
138 (select-window win) | |
139 (goto-char pos) | |
140 (when (equal arg 2) | |
141 (select-window pop-win))))) | |
142 | |
143 (defun reftex-view-cr-ref (arg label how) | |
144 ;; View crossreference of a ref macro. HOW can have the values | |
145 ;; nil: Show in another window. | |
146 ;; echo: Show one-line info in echo area. | |
147 ;; tmp-window: Show in small window and arrange for window to disappear. | |
148 | |
149 ;; Ensure access to scanning info | |
150 (reftex-access-scan-info (or arg current-prefix-arg)) | |
151 | |
152 (if (eq how 'tmp-window) | |
153 ;; Remember the window configuration | |
154 (put 'reftex-auto-view-crossref 'last-window-conf | |
155 (current-window-configuration))) | |
156 | |
157 (let* ((xr-data (assoc 'xr (symbol-value reftex-docstruct-symbol))) | |
158 (xr-re (nth 2 xr-data)) | |
159 (entry (assoc label (symbol-value reftex-docstruct-symbol))) | |
160 (win (selected-window)) pop-win (pos (point))) | |
161 | |
162 (if (and (not entry) (stringp label) xr-re (string-match xr-re label)) | |
163 ;; Label is defined in external document | |
164 (save-excursion | |
165 (save-match-data | |
166 (set-buffer | |
167 (or (reftex-get-file-buffer-force | |
168 (cdr (assoc (match-string 1 label) (nth 1 | |
169 xr-data)))) | |
170 (error "Problem with external label %s" label)))) | |
171 (setq label (substring label (match-end 1))) | |
172 (reftex-access-scan-info) | |
173 (setq entry | |
174 (assoc label (symbol-value reftex-docstruct-symbol))))) | |
175 (if (eq how 'echo) | |
176 ;; Display in echo area | |
177 (reftex-echo-ref label entry (symbol-value reftex-docstruct-symbol)) | |
178 (let ((window-conf (current-window-configuration))) | |
179 (condition-case nil | |
180 (reftex-show-label-location entry t nil t t) | |
181 (error (set-window-configuration window-conf) | |
182 (message "ref: Label %s not found" label) | |
183 (error "ref: Label %s not found" label)))) ;; 2nd is line OK | |
184 (add-hook 'pre-command-hook 'reftex-highlight-shall-die) | |
185 | |
186 (when (eq how 'tmp-window) | |
187 ;; Resize window and arrange restauration | |
188 (shrink-window (1- (- (window-height) 9))) | |
189 (recenter '(4)) | |
190 (add-hook 'pre-command-hook 'reftex-restore-window-conf)) | |
191 (setq pop-win (selected-window)) | |
192 (select-window win) | |
193 (goto-char pos) | |
194 (when (equal arg 2) | |
195 (select-window pop-win))))) | |
196 | |
197 (defun reftex-mouse-view-crossref (ev) | |
198 "View cross reference of \\ref or \\cite macro where you click. | |
199 If the macro at point is a \\ref, show the corresponding label definition. | |
200 If it is a \\cite, show the BibTeX database entry. | |
201 If there is no such macro at point, search forward to find one. | |
202 With argument, actually select the window showing the cross reference." | |
203 (interactive "e") | |
204 (mouse-set-point ev) | |
205 (reftex-view-crossref current-prefix-arg)) | |
206 | |
207 (defun reftex-view-crossref-when-idle () | |
208 ;; Display info about crossref at point in echo area or a window. | |
209 ;; This function was desigend to work with an idle timer. | |
210 ;; We try to get out of here as quickly as possible if the call is useless. | |
211 (and reftex-mode | |
212 ;; Make sure message area is free if we need it. | |
213 (or (eq reftex-auto-view-crossref 'window) (not (current-message))) | |
214 ;; Make sure we are not already displaying this one | |
215 (not (memq last-command '(reftex-view-crossref | |
216 reftex-mouse-view-crossref))) | |
217 ;; Quick precheck if this might be a relevant spot | |
218 ;; FIXME: Can fail with backslash in comment | |
219 (save-excursion | |
220 (search-backward "\\" nil t) | |
221 (looking-at "\\\\[a-zA-Z]*\\(cite\\|ref\\)")) | |
222 | |
223 (condition-case nil | |
224 (let ((current-prefix-arg nil)) | |
225 (cond | |
226 ((eq reftex-auto-view-crossref t) | |
227 (reftex-view-crossref -1 'echo)) | |
228 ((eq reftex-auto-view-crossref 'window) | |
229 (reftex-view-crossref -1 'tmp-window)) | |
230 (t nil))) | |
231 (error nil)))) | |
232 | |
233 (defun reftex-restore-window-conf () | |
234 (set-window-configuration (get 'reftex-auto-view-crossref 'last-window-conf)) | |
235 (put 'reftex-auto-view-crossref 'last-window-conf nil) | |
236 (remove-hook 'pre-command-hook 'reftex-restore-window-conf)) | |
237 | |
238 (defun reftex-echo-ref (label entry docstruct) | |
239 ;; Display crossref info in echo area. | |
240 (cond | |
241 ((null docstruct) | |
242 (message (substitute-command-keys (format reftex-no-info-message "ref")))) | |
243 ((null entry) | |
244 (message "ref: unknown label: %s" label)) | |
245 (t | |
246 (when (stringp (nth 2 entry)) | |
247 (message "ref(%s): %s" (nth 1 entry) (nth 2 entry))) | |
248 (let ((buf (get-buffer " *Echo Area*"))) | |
249 (when buf | |
250 (save-excursion | |
251 (set-buffer buf) | |
252 (run-hooks 'reftex-display-copied-context-hook))))))) | |
253 | |
254 (defun reftex-echo-cite (key files item) | |
255 ;; Display citation info in echo area. | |
256 (let* ((cache (assq 'bibview-cache (symbol-value reftex-docstruct-symbol))) | |
257 (cache-entry (assoc key (cdr cache))) | |
258 entry string buf (all-files files)) | |
259 | |
260 (if (and reftex-cache-cite-echo cache-entry) | |
261 ;; We can just use the cache | |
262 (setq string (cdr cache-entry)) | |
263 | |
264 ;; Need to look in the database | |
265 (unless reftex-revisit-to-echo | |
266 (setq files (reftex-visited-files files))) | |
267 | |
268 (setq entry | |
269 (condition-case nil | |
270 (save-excursion | |
271 (reftex-pop-to-bibtex-entry key files nil nil item t)) | |
272 (error | |
273 (if (and files (= (length all-files) (length files))) | |
274 (message "cite: no such database entry: %s" key) | |
275 (message (substitute-command-keys | |
276 (format reftex-no-info-message "cite")))) | |
277 nil))) | |
278 (when entry | |
279 (if item | |
280 (setq string (reftex-nicify-text entry)) | |
281 (setq string (reftex-make-cite-echo-string | |
282 (reftex-parse-bibtex-entry entry) | |
283 reftex-docstruct-symbol))))) | |
284 (unless (or (null string) (equal string "")) | |
285 (message "cite: %s" string)) | |
286 (when (setq buf (get-buffer " *Echo Area*")) | |
287 (save-excursion | |
288 (set-buffer buf) | |
289 (run-hooks 'reftex-display-copied-context-hook))))) | |
290 | |
291 (defvar reftex-use-itimer-in-xemacs nil | |
292 "*Non-nil means use the idle timers in XEmacs for crossref display. | |
293 Currently, idle timer restart is broken and we use the post-command-hook.") | |
294 | |
295 (defun reftex-toggle-auto-view-crossref () | |
296 "Toggle the automatic display of crossref information in the echo area. | |
297 When active, leaving point idle in the argument of a \\ref or \\cite macro | |
298 will display info in the echo area." | |
299 (interactive) | |
300 (if reftex-auto-view-crossref-timer | |
301 (progn | |
302 (if (featurep 'xemacs) | |
303 (if reftex-use-itimer-in-xemacs | |
304 (delete-itimer reftex-auto-view-crossref-timer) | |
305 (remove-hook 'post-command-hook 'reftex-start-itimer-once)) | |
306 (cancel-timer reftex-auto-view-crossref-timer)) | |
307 (setq reftex-auto-view-crossref-timer nil) | |
308 (message "Automatic display of crossref information was turned off")) | |
309 (setq reftex-auto-view-crossref-timer | |
310 (if (featurep 'xemacs) | |
311 (if reftex-use-itimer-in-xemacs | |
312 (start-itimer "RefTeX Idle Timer" | |
313 'reftex-view-crossref-when-idle | |
314 reftex-idle-time reftex-idle-time t) | |
315 (add-hook 'post-command-hook 'reftex-start-itimer-once) | |
316 t) | |
317 (run-with-idle-timer | |
318 reftex-idle-time t 'reftex-view-crossref-when-idle))) | |
319 (unless reftex-auto-view-crossref | |
320 (setq reftex-auto-view-crossref t)) | |
321 (message "Automatic display of crossref information was turned on"))) | |
322 | |
323 (defun reftex-start-itimer-once () | |
324 (and reftex-mode | |
325 (not (itimer-live-p reftex-auto-view-crossref-timer)) | |
326 (setq reftex-auto-view-crossref-timer | |
327 (start-itimer "RefTeX Idle Timer" | |
328 'reftex-view-crossref-when-idle | |
329 reftex-idle-time nil t)))) | |
330 | |
331 (defun reftex-view-crossref-from-bibtex (&optional arg) | |
332 "View location in a LaTeX document which cites the BibTeX entry at point. | |
333 Since BibTeX files can be used by many LaTeX documents, this function | |
334 prompts upon first use for a buffer in RefTeX mode. To reset this | |
335 link to a document, call the function with with a prefix arg. | |
336 Calling this function several times find successive citation locations." | |
337 (interactive "P") | |
338 (when arg | |
339 ;; Break connection to reference buffer | |
340 (remprop 'reftex-bibtex-view-cite-locations :ref-buffer)) | |
341 (let ((ref-buffer (get 'reftex-bibtex-view-cite-locations :ref-buffer))) | |
342 ;; Establish connection to reference buffer | |
343 (unless ref-buffer | |
344 (setq ref-buffer | |
345 (save-excursion | |
346 (completing-read | |
347 "Reference buffer: " | |
348 (delq nil | |
349 (mapcar | |
350 (lambda (b) | |
351 (set-buffer b) | |
352 (if reftex-mode (list (buffer-name b)) nil)) | |
353 (buffer-list))) | |
354 nil t))) | |
355 (put 'reftex-bibtex-view-cite-locations :ref-buffer ref-buffer)) | |
356 ;; Search for citations | |
357 (bibtex-beginning-of-entry) | |
358 (if (looking-at | |
359 "@[a-zA-Z]+[ \t\n\r]*[{(][ \t\n\r]*\\([^, \t\r\n}]+\\)") | |
360 (progn | |
361 (goto-char (match-beginning 1)) | |
362 (reftex-view-regexp-match | |
363 (format reftex-find-citation-regexp-format | |
364 (regexp-quote (match-string 1))) | |
365 3 arg ref-buffer)) | |
366 (error "Cannot find citation key in BibTeX entry")))) | |
367 | |
368 (defun reftex-view-regexp-match (re &optional highlight-group new ref-buffer) | |
369 ;; Search for RE in current document or in the document of REF-BUFFER. | |
370 ;; Continue the search, if the same re was searched last. | |
371 ;; Highlight the group HIGHLIGHT-GROUP of the match. | |
372 ;; When NEW is non-nil, start a new search regardless. | |
373 ;; Match point is displayed in another window. | |
374 ;; Upon success, returns the window which displays the match. | |
375 | |
376 ;;; Decide if new search or continued search | |
377 (let* ((oldprop (get 'reftex-view-regexp-match :props)) | |
378 (newprop (list (current-buffer) re)) | |
379 (cont (and (not new) (equal oldprop newprop))) | |
380 (cnt (if cont (get 'reftex-view-regexp-match :cnt) 0)) | |
381 (current-window (selected-window)) | |
382 (window-conf (current-window-configuration)) | |
383 match pop-window) | |
384 (switch-to-buffer-other-window (or ref-buffer (current-buffer))) | |
385 ;; Search | |
386 (condition-case nil | |
387 (if cont | |
388 (setq match (reftex-global-search-continue)) | |
389 (reftex-access-scan-info) | |
390 (setq match (reftex-global-search re (reftex-all-document-files)))) | |
391 (error nil)) | |
392 ;; Evaluate the match. | |
393 (if match | |
394 (progn | |
395 (put 'reftex-view-regexp-match :props newprop) | |
396 (put 'reftex-view-regexp-match :cnt (incf cnt)) | |
397 (reftex-highlight 0 (match-beginning highlight-group) | |
398 (match-end highlight-group)) | |
399 (add-hook 'pre-command-hook 'reftex-highlight-shall-die) | |
400 (setq pop-window (selected-window))) | |
401 (remprop 'reftex-view-regexp-match :props) | |
402 (or cont (set-window-configuration window-conf))) | |
403 (select-window current-window) | |
404 (if match | |
405 (progn | |
406 (message "Match Nr. %s" cnt) | |
407 pop-window) | |
408 (if cont | |
409 (error "No further matches (total number of matches: %d)" cnt) | |
410 (error "No matches"))))) | |
411 | |
412 (defvar reftex-global-search-marker (make-marker)) | |
413 (defun reftex-global-search (regexp file-list) | |
414 ;; Start a search for REGEXP in all files of FILE-LIST | |
415 (put 'reftex-global-search :file-list file-list) | |
416 (put 'reftex-global-search :regexp regexp) | |
417 (move-marker reftex-global-search-marker nil) | |
418 (reftex-global-search-continue)) | |
419 | |
420 (defun reftex-global-search-continue () | |
421 ;; Continue a global search started with `reftex-global-search' | |
422 (unless (get 'reftex-global-search :file-list) | |
423 (error "No global search to continue")) | |
424 (let* ((file-list (get 'reftex-global-search :file-list)) | |
425 (regexp (get 'reftex-global-search :regexp)) | |
426 (buf (or (marker-buffer reftex-global-search-marker) | |
427 (reftex-get-file-buffer-force (car file-list)))) | |
428 (pos (or (marker-position reftex-global-search-marker) 1)) | |
429 file) | |
430 ;; Take up starting position | |
431 (unless buf (error "No such buffer %s" buf)) | |
432 (switch-to-buffer buf) | |
433 (widen) | |
434 (goto-char pos) | |
435 ;; Search and switch file if necessary | |
436 (if (catch 'exit | |
437 (while t | |
438 (when (re-search-forward regexp nil t) | |
439 (move-marker reftex-global-search-marker (point)) | |
440 (throw 'exit t)) | |
441 ;; No match - goto next file | |
442 (pop file-list) | |
443 (or file-list (throw 'exit nil)) | |
444 (setq file (car file-list) | |
445 buf (reftex-get-file-buffer-force file)) | |
446 (unless buf (error "Cannot access file %s" file)) | |
447 (put 'reftex-global-search :file-list file-list) | |
448 (switch-to-buffer buf) | |
449 (widen) | |
450 (goto-char 1))) | |
451 t | |
452 (move-marker reftex-global-search-marker nil) | |
453 (error "All files processed")))) | |
454 | |
455 ;;; reftex-vcr.el ends here |