| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
(eval-when-compile (require 'cl)) |
|---|
| 32 |
(provide 'reftex-dcr) |
|---|
| 33 |
(provide 'reftex-vcr) |
|---|
| 34 |
(require 'reftex) |
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
(defun reftex-view-crossref (&optional arg auto-how fail-quietly) |
|---|
| 38 |
"View cross reference of macro at point. Point must be on the KEY |
|---|
| 39 |
argument. When at at `\\ref' macro, show corresponding `\\label' |
|---|
| 40 |
definition, also in external documents (`xr'). When on a label, show |
|---|
| 41 |
a locations where KEY is referenced. Subsequent calls find additional |
|---|
| 42 |
locations. When on a `\\cite', show the associated `\\bibitem' macro or |
|---|
| 43 |
the BibTeX database entry. When on a `\\bibitem', show a `\\cite' macro |
|---|
| 44 |
which uses this KEY. When on an `\\index', show other locations marked |
|---|
| 45 |
by the same index entry. |
|---|
| 46 |
To define additional cross referencing items, use the option |
|---|
| 47 |
`reftex-view-crossref-extra'. See also `reftex-view-crossref-from-bibtex'. |
|---|
| 48 |
With one or two C-u prefixes, enforce rescanning of the document. |
|---|
| 49 |
With argument 2, select the window showing the cross reference. |
|---|
| 50 |
AUTO-HOW is only for the automatic crossref display and is handed through |
|---|
| 51 |
to the functions `reftex-view-cr-cite' and `reftex-view-cr-ref'." |
|---|
| 52 |
|
|---|
| 53 |
(interactive "P") |
|---|
| 54 |
|
|---|
| 55 |
(let* ((macro (car (reftex-what-macro-safe 1))) |
|---|
| 56 |
(key (reftex-this-word "^{}%\n\r, \t")) |
|---|
| 57 |
dw) |
|---|
| 58 |
|
|---|
| 59 |
(if (or (null macro) (reftex-in-comment)) |
|---|
| 60 |
(or fail-quietly |
|---|
| 61 |
(error "Not on a crossref macro argument")) |
|---|
| 62 |
|
|---|
| 63 |
(setq reftex-call-back-to-this-buffer (current-buffer)) |
|---|
| 64 |
|
|---|
| 65 |
(cond |
|---|
| 66 |
((string-match "\\`\\\\cite\\|cite\\*?\\'\\|bibentry" macro) |
|---|
| 67 |
|
|---|
| 68 |
(setq dw (reftex-view-cr-cite arg key auto-how))) |
|---|
| 69 |
((string-match "\\`\\\\ref\\|ref\\(range\\)?\\*?\\'" macro) |
|---|
| 70 |
|
|---|
| 71 |
(setq dw (reftex-view-cr-ref arg key auto-how))) |
|---|
| 72 |
(auto-how nil) |
|---|
| 73 |
((or (equal macro "\\label") |
|---|
| 74 |
(member macro reftex-macros-with-labels)) |
|---|
| 75 |
|
|---|
| 76 |
(reftex-access-scan-info arg) |
|---|
| 77 |
(setq dw (reftex-view-regexp-match |
|---|
| 78 |
(format reftex-find-reference-format (regexp-quote key)) |
|---|
| 79 |
4 nil nil))) |
|---|
| 80 |
((equal macro "\\bibitem") |
|---|
| 81 |
|
|---|
| 82 |
(reftex-access-scan-info arg) |
|---|
| 83 |
(setq dw (reftex-view-regexp-match |
|---|
| 84 |
(format reftex-find-citation-regexp-format (regexp-quote key)) |
|---|
| 85 |
4 nil nil))) |
|---|
| 86 |
((member macro reftex-macros-with-index) |
|---|
| 87 |
(reftex-access-scan-info arg) |
|---|
| 88 |
(setq dw (reftex-view-regexp-match |
|---|
| 89 |
(format reftex-find-index-entry-regexp-format |
|---|
| 90 |
(regexp-quote key)) |
|---|
| 91 |
3 nil nil))) |
|---|
| 92 |
(t |
|---|
| 93 |
(reftex-access-scan-info arg) |
|---|
| 94 |
(catch 'exit |
|---|
| 95 |
(let ((list reftex-view-crossref-extra) |
|---|
| 96 |
entry mre action group) |
|---|
| 97 |
(while (setq entry (pop list)) |
|---|
| 98 |
(setq mre (car entry) |
|---|
| 99 |
action (nth 1 entry) |
|---|
| 100 |
group (nth 2 entry)) |
|---|
| 101 |
(when (string-match mre macro) |
|---|
| 102 |
(setq dw (reftex-view-regexp-match |
|---|
| 103 |
(format action key) group nil nil)) |
|---|
| 104 |
(throw 'exit t)))) |
|---|
| 105 |
(error "Not on a crossref macro argument")))) |
|---|
| 106 |
(if (and (eq arg 2) (windowp dw)) (select-window dw))))) |
|---|
| 107 |
|
|---|
| 108 |
(defun reftex-view-cr-cite (arg key how) |
|---|
| 109 |
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 |
|
|---|
| 115 |
(reftex-access-scan-info (or arg current-prefix-arg)) |
|---|
| 116 |
|
|---|
| 117 |
(if (eq how 'tmp-window) |
|---|
| 118 |
|
|---|
| 119 |
(put 'reftex-auto-view-crossref 'last-window-conf |
|---|
| 120 |
(current-window-configuration))) |
|---|
| 121 |
|
|---|
| 122 |
(let (files size item (pos (point)) (win (selected-window)) pop-win |
|---|
| 123 |
(bibtype (reftex-bib-or-thebib))) |
|---|
| 124 |
|
|---|
| 125 |
(cond |
|---|
| 126 |
|
|---|
| 127 |
((eq bibtype 'bib) |
|---|
| 128 |
(setq item nil |
|---|
| 129 |
files (reftex-get-bibfile-list))) |
|---|
| 130 |
|
|---|
| 131 |
((eq bibtype 'thebib) |
|---|
| 132 |
(setq item t |
|---|
| 133 |
files (reftex-uniquify |
|---|
| 134 |
(mapcar 'cdr |
|---|
| 135 |
(reftex-all-assq |
|---|
| 136 |
'thebib (symbol-value reftex-docstruct-symbol)))))) |
|---|
| 137 |
(reftex-default-bibliography |
|---|
| 138 |
(setq item nil |
|---|
| 139 |
files (reftex-default-bibliography))) |
|---|
| 140 |
(how) |
|---|
| 141 |
(t (error "Cannot display crossref"))) |
|---|
| 142 |
|
|---|
| 143 |
(if (eq how 'echo) |
|---|
| 144 |
|
|---|
| 145 |
(reftex-echo-cite key files item) |
|---|
| 146 |
|
|---|
| 147 |
(if (not (eq how 'tmp-window)) |
|---|
| 148 |
|
|---|
| 149 |
(reftex-pop-to-bibtex-entry key files nil t item) |
|---|
| 150 |
|
|---|
| 151 |
(condition-case nil |
|---|
| 152 |
(reftex-pop-to-bibtex-entry key files nil t item) |
|---|
| 153 |
(error (goto-char pos) |
|---|
| 154 |
(message "cite: no such citation key %s" key) |
|---|
| 155 |
(error ""))) |
|---|
| 156 |
|
|---|
| 157 |
(setq size (max 1 (count-lines (point) |
|---|
| 158 |
(reftex-end-of-bib-entry item)))) |
|---|
| 159 |
(let ((window-min-height 2)) |
|---|
| 160 |
(shrink-window (1- (- (window-height) size))) |
|---|
| 161 |
(recenter 0)) |
|---|
| 162 |
|
|---|
| 163 |
(add-hook 'pre-command-hook 'reftex-restore-window-conf)) |
|---|
| 164 |
|
|---|
| 165 |
|
|---|
| 166 |
(add-hook 'pre-command-hook 'reftex-highlight-shall-die) |
|---|
| 167 |
(setq pop-win (selected-window)) |
|---|
| 168 |
(select-window win) |
|---|
| 169 |
(goto-char pos) |
|---|
| 170 |
(when (equal arg 2) |
|---|
| 171 |
(select-window pop-win))))) |
|---|
| 172 |
|
|---|
| 173 |
(defun reftex-view-cr-ref (arg label how) |
|---|
| 174 |
|
|---|
| 175 |
|
|---|
| 176 |
|
|---|
| 177 |
|
|---|
| 178 |
|
|---|
| 179 |
|
|---|
| 180 |
(reftex-access-scan-info (or arg current-prefix-arg)) |
|---|
| 181 |
|
|---|
| 182 |
(if (eq how 'tmp-window) |
|---|
| 183 |
|
|---|
| 184 |
(put 'reftex-auto-view-crossref 'last-window-conf |
|---|
| 185 |
(current-window-configuration))) |
|---|
| 186 |
|
|---|
| 187 |
(let* ((xr-data (assoc 'xr (symbol-value reftex-docstruct-symbol))) |
|---|
| 188 |
(xr-re (nth 2 xr-data)) |
|---|
| 189 |
(entry (assoc label (symbol-value reftex-docstruct-symbol))) |
|---|
| 190 |
(win (selected-window)) pop-win (pos (point))) |
|---|
| 191 |
|
|---|
| 192 |
(if (and (not entry) (stringp label) xr-re (string-match xr-re label)) |
|---|
| 193 |
|
|---|
| 194 |
(save-excursion |
|---|
| 195 |
(save-match-data |
|---|
| 196 |
(set-buffer |
|---|
| 197 |
(or (reftex-get-file-buffer-force |
|---|
| 198 |
(cdr (assoc (match-string 1 label) (nth 1 |
|---|
| 199 |
xr-data)))) |
|---|
| 200 |
(error "Problem with external label %s" label)))) |
|---|
| 201 |
(setq label (substring label (match-end 1))) |
|---|
| 202 |
(reftex-access-scan-info) |
|---|
| 203 |
(setq entry |
|---|
| 204 |
(assoc label (symbol-value reftex-docstruct-symbol))))) |
|---|
| 205 |
(if (eq how 'echo) |
|---|
| 206 |
|
|---|
| 207 |
(reftex-echo-ref label entry (symbol-value reftex-docstruct-symbol)) |
|---|
| 208 |
(let ((window-conf (current-window-configuration))) |
|---|
| 209 |
(condition-case nil |
|---|
| 210 |
(reftex-show-label-location entry t nil t t) |
|---|
| 211 |
(error (set-window-configuration window-conf) |
|---|
| 212 |
(message "ref: Label %s not found" label) |
|---|
| 213 |
(error "ref: Label %s not found" label)))) |
|---|
| 214 |
(add-hook 'pre-command-hook 'reftex-highlight-shall-die) |
|---|
| 215 |
|
|---|
| 216 |
(when (eq how 'tmp-window) |
|---|
| 217 |
|
|---|
| 218 |
(shrink-window (1- (- (window-height) 9))) |
|---|
| 219 |
(recenter '(4)) |
|---|
| 220 |
(add-hook 'pre-command-hook 'reftex-restore-window-conf)) |
|---|
| 221 |
(setq pop-win (selected-window)) |
|---|
| 222 |
(select-window win) |
|---|
| 223 |
(goto-char pos) |
|---|
| 224 |
(when (equal arg 2) |
|---|
| 225 |
(select-window pop-win))))) |
|---|
| 226 |
|
|---|
| 227 |
(defun reftex-mouse-view-crossref (ev) |
|---|
| 228 |
"View cross reference of \\ref or \\cite macro where you click. |
|---|
| 229 |
If the macro at point is a \\ref, show the corresponding label definition. |
|---|
| 230 |
If it is a \\cite, show the BibTeX database entry. |
|---|
| 231 |
If there is no such macro at point, search forward to find one. |
|---|
| 232 |
With argument, actually select the window showing the cross reference." |
|---|
| 233 |
(interactive "e") |
|---|
| 234 |
(mouse-set-point ev) |
|---|
| 235 |
(reftex-view-crossref current-prefix-arg)) |
|---|
| 236 |
|
|---|
| 237 |
(defun reftex-view-crossref-when-idle () |
|---|
| 238 |
|
|---|
| 239 |
|
|---|
| 240 |
|
|---|
| 241 |
(and reftex-mode |
|---|
| 242 |
|
|---|
| 243 |
(or (eq reftex-auto-view-crossref 'window) (not (current-message))) |
|---|
| 244 |
|
|---|
| 245 |
(not (memq last-command '(reftex-view-crossref |
|---|
| 246 |
reftex-mouse-view-crossref))) |
|---|
| 247 |
|
|---|
| 248 |
|
|---|
| 249 |
(save-excursion |
|---|
| 250 |
(search-backward "\\" nil t) |
|---|
| 251 |
(looking-at "\\\\[a-zA-Z]*\\(cite\\|ref\\|bibentry\\)")) |
|---|
| 252 |
|
|---|
| 253 |
(condition-case nil |
|---|
| 254 |
(let ((current-prefix-arg nil)) |
|---|
| 255 |
(cond |
|---|
| 256 |
((eq reftex-auto-view-crossref t) |
|---|
| 257 |
(reftex-view-crossref -1 'echo 'quiet)) |
|---|
| 258 |
((eq reftex-auto-view-crossref 'window) |
|---|
| 259 |
(reftex-view-crossref -1 'tmp-window 'quiet)) |
|---|
| 260 |
(t nil))) |
|---|
| 261 |
(error nil)))) |
|---|
| 262 |
|
|---|
| 263 |
(defun reftex-restore-window-conf () |
|---|
| 264 |
(set-window-configuration (get 'reftex-auto-view-crossref 'last-window-conf)) |
|---|
| 265 |
(put 'reftex-auto-view-crossref 'last-window-conf nil) |
|---|
| 266 |
(remove-hook 'pre-command-hook 'reftex-restore-window-conf)) |
|---|
| 267 |
|
|---|
| 268 |
(defun reftex-echo-ref (label entry docstruct) |
|---|
| 269 |
|
|---|
| 270 |
(cond |
|---|
| 271 |
((null docstruct) |
|---|
| 272 |
(message "%s" |
|---|
| 273 |
(substitute-command-keys (format reftex-no-info-message "ref")))) |
|---|
| 274 |
((null entry) |
|---|
| 275 |
(message "ref: unknown label: %s" label)) |
|---|
| 276 |
(t |
|---|
| 277 |
(when (stringp (nth 2 entry)) |
|---|
| 278 |
(message "ref(%s): %s" (nth 1 entry) (nth 2 entry))) |
|---|
| 279 |
(let ((buf (get-buffer " *Echo Area*"))) |
|---|
| 280 |
(when buf |
|---|
| 281 |
(save-excursion |
|---|
| 282 |
(set-buffer buf) |
|---|
| 283 |
(run-hooks 'reftex-display-copied-context-hook))))))) |
|---|
| 284 |
|
|---|
| 285 |
(defun reftex-echo-cite (key files item) |
|---|
| 286 |
|
|---|
| 287 |
(let* ((cache (assq 'bibview-cache (symbol-value reftex-docstruct-symbol))) |
|---|
| 288 |
(cache-entry (assoc key (cdr cache))) |
|---|
| 289 |
entry string buf (all-files files)) |
|---|
| 290 |
|
|---|
| 291 |
(if (and reftex-cache-cite-echo cache-entry) |
|---|
| 292 |
|
|---|
| 293 |
(setq string (cdr cache-entry)) |
|---|
| 294 |
|
|---|
| 295 |
|
|---|
| 296 |
(unless reftex-revisit-to-echo |
|---|
| 297 |
(setq files (reftex-visited-files files))) |
|---|
| 298 |
|
|---|
| 299 |
(setq entry |
|---|
| 300 |
(condition-case nil |
|---|
| 301 |
(save-excursion |
|---|
| 302 |
(reftex-pop-to-bibtex-entry key files nil nil item t)) |
|---|
| 303 |
(error |
|---|
| 304 |
(if (and files (= (length all-files) (length files))) |
|---|
| 305 |
(message "cite: no such database entry: %s" key) |
|---|
| 306 |
(message "%s" (substitute-command-keys |
|---|
| 307 |
(format reftex-no-info-message "cite")))) |
|---|
| 308 |
nil))) |
|---|
| 309 |
(when entry |
|---|
| 310 |
(if item |
|---|
| 311 |
(setq string (reftex-nicify-text entry)) |
|---|
| 312 |
(setq string (reftex-make-cite-echo-string |
|---|
| 313 |
(reftex-parse-bibtex-entry entry) |
|---|
| 314 |
reftex-docstruct-symbol))))) |
|---|
| 315 |
(unless (or (null string) (equal string "")) |
|---|
| 316 |
(message "cite: %s" string)) |
|---|
| 317 |
(when (setq buf (get-buffer " *Echo Area*")) |
|---|
| 318 |
(save-excursion |
|---|
| 319 |
(set-buffer buf) |
|---|
| 320 |
(run-hooks 'reftex-display-copied-context-hook))))) |
|---|
| 321 |
|
|---|
| 322 |
(defvar reftex-use-itimer-in-xemacs nil |
|---|
| 323 |
"*Non-nil means use the idle timers in XEmacs for crossref display. |
|---|
| 324 |
Currently, idle timer restart is broken and we use the post-command-hook.") |
|---|
| 325 |
|
|---|
| 326 |
(defun reftex-toggle-auto-view-crossref () |
|---|
| 327 |
"Toggle the automatic display of crossref information in the echo area. |
|---|
| 328 |
When active, leaving point idle in the argument of a \\ref or \\cite macro |
|---|
| 329 |
will display info in the echo area." |
|---|
| 330 |
(interactive) |
|---|
| 331 |
(if reftex-auto-view-crossref-timer |
|---|
| 332 |
(progn |
|---|
| 333 |
(if (featurep 'xemacs) |
|---|
| 334 |
(if reftex-use-itimer-in-xemacs |
|---|
| 335 |
(delete-itimer reftex-auto-view-crossref-timer) |
|---|
| 336 |
(remove-hook 'post-command-hook 'reftex-start-itimer-once)) |
|---|
| 337 |
(cancel-timer reftex-auto-view-crossref-timer)) |
|---|
| 338 |
(setq reftex-auto-view-crossref-timer nil) |
|---|
| 339 |
(message "Automatic display of crossref information was turned off")) |
|---|
| 340 |
(setq reftex-auto-view-crossref-timer |
|---|
| 341 |
(if (featurep 'xemacs) |
|---|
| 342 |
(if reftex-use-itimer-in-xemacs |
|---|
| 343 |
(start-itimer "RefTeX Idle Timer" |
|---|
| 344 |
'reftex-view-crossref-when-idle |
|---|
| 345 |
reftex-idle-time reftex-idle-time t) |
|---|
| 346 |
(add-hook 'post-command-hook 'reftex-start-itimer-once) |
|---|
| 347 |
t) |
|---|
| 348 |
(run-with-idle-timer |
|---|
| 349 |
reftex-idle-time t 'reftex-view-crossref-when-idle))) |
|---|
| 350 |
(unless reftex-auto-view-crossref |
|---|
| 351 |
(setq reftex-auto-view-crossref t)) |
|---|
| 352 |
(message "Automatic display of crossref information was turned on"))) |
|---|
| 353 |
|
|---|
| 354 |
(defun reftex-start-itimer-once () |
|---|
| 355 |
(and reftex-mode |
|---|
| 356 |
(not (itimer-live-p reftex-auto-view-crossref-timer)) |
|---|
| 357 |
(setq reftex-auto-view-crossref-timer |
|---|
| 358 |
(start-itimer "RefTeX Idle Timer" |
|---|
| 359 |
'reftex-view-crossref-when-idle |
|---|
| 360 |
reftex-idle-time nil t)))) |
|---|
| 361 |
|
|---|
| 362 |
(defun reftex-view-crossref-from-bibtex (&optional arg) |
|---|
| 363 |
"View location in a LaTeX document which cites the BibTeX entry at point. |
|---|
| 364 |
Since BibTeX files can be used by many LaTeX documents, this function |
|---|
| 365 |
prompts upon first use for a buffer in RefTeX mode. To reset this |
|---|
| 366 |
link to a document, call the function with with a prefix arg. |
|---|
| 367 |
Calling this function several times find successive citation locations." |
|---|
| 368 |
(interactive "P") |
|---|
| 369 |
(when arg |
|---|
| 370 |
|
|---|
| 371 |
(put 'reftex-bibtex-view-cite-locations :ref-buffer nil)) |
|---|
| 372 |
(let ((ref-buffer (get 'reftex-bibtex-view-cite-locations :ref-buffer))) |
|---|
| 373 |
|
|---|
| 374 |
(unless ref-buffer |
|---|
| 375 |
(setq ref-buffer |
|---|
| 376 |
(save-excursion |
|---|
| 377 |
(completing-read |
|---|
| 378 |
"Reference buffer: " |
|---|
| 379 |
(delq nil |
|---|
| 380 |
(mapcar |
|---|
| 381 |
(lambda (b) |
|---|
| 382 |
(set-buffer b) |
|---|
| 383 |
(if reftex-mode (list (buffer-name b)) nil)) |
|---|
| 384 |
(buffer-list))) |
|---|
| 385 |
nil t))) |
|---|
| 386 |
(put 'reftex-bibtex-view-cite-locations :ref-buffer ref-buffer)) |
|---|
| 387 |
|
|---|
| 388 |
(bibtex-beginning-of-entry) |
|---|
| 389 |
(if (looking-at |
|---|
| 390 |
"@[a-zA-Z]+[ \t\n\r]*[{(][ \t\n\r]*\\([^, \t\r\n}]+\\)") |
|---|
| 391 |
(progn |
|---|
| 392 |
(goto-char (match-beginning 1)) |
|---|
| 393 |
(reftex-view-regexp-match |
|---|
| 394 |
(format reftex-find-citation-regexp-format |
|---|
| 395 |
(regexp-quote (match-string 1))) |
|---|
| 396 |
4 arg ref-buffer)) |
|---|
| 397 |
(error "Cannot find citation key in BibTeX entry")))) |
|---|
| 398 |
|
|---|
| 399 |
(defun reftex-view-regexp-match (re &optional highlight-group new ref-buffer) |
|---|
| 400 |
|
|---|
| 401 |
|
|---|
| 402 |
|
|---|
| 403 |
|
|---|
| 404 |
|
|---|
| 405 |
|
|---|
| 406 |
|
|---|
| 407 |
|
|---|
| 408 |
(let* ((oldprop (get 'reftex-view-regexp-match :props)) |
|---|
| 409 |
(newprop (list (current-buffer) re)) |
|---|
| 410 |
(cont (and (not new) (equal oldprop newprop))) |
|---|
| 411 |
(cnt (if cont (get 'reftex-view-regexp-match :cnt) 0)) |
|---|
| 412 |
(current-window (selected-window)) |
|---|
| 413 |
(window-conf (current-window-configuration)) |
|---|
| 414 |
match pop-window) |
|---|
| 415 |
(switch-to-buffer-other-window (or ref-buffer (current-buffer))) |
|---|
| 416 |
|
|---|
| 417 |
(condition-case nil |
|---|
| 418 |
(if cont |
|---|
| 419 |
(setq match (reftex-global-search-continue)) |
|---|
| 420 |
(reftex-access-scan-info) |
|---|
| 421 |
(setq match (reftex-global-search re (reftex-all-document-files)))) |
|---|
| 422 |
(error nil)) |
|---|
| 423 |
|
|---|
| 424 |
(if match |
|---|
| 425 |
(progn |
|---|
| 426 |
(put 'reftex-view-regexp-match :props newprop) |
|---|
| 427 |
(put 'reftex-view-regexp-match :cnt (incf cnt)) |
|---|
| 428 |
(reftex-highlight 0 (match-beginning highlight-group) |
|---|
| 429 |
(match-end highlight-group)) |
|---|
| 430 |
(add-hook 'pre-command-hook 'reftex-highlight-shall-die) |
|---|
| 431 |
(setq pop-window (selected-window))) |
|---|
| 432 |
(put 'reftex-view-regexp-match :props nil) |
|---|
| 433 |
(or cont (set-window-configuration window-conf))) |
|---|
| 434 |
(select-window current-window) |
|---|
| 435 |
(if match |
|---|
| 436 |
(progn |
|---|
| 437 |
(message "Match Nr. %s" cnt) |
|---|
| 438 |
pop-window) |
|---|
| 439 |
(if cont |
|---|
| 440 |
(error "No further matches (total number of matches: %d)" cnt) |
|---|
| 441 |
(error "No matches"))))) |
|---|
| 442 |
|
|---|
| 443 |
(defvar reftex-global-search-marker (make-marker)) |
|---|
| 444 |
(defun reftex-global-search (regexp file-list) |
|---|
| 445 |
|
|---|
| 446 |
(put 'reftex-global-search :file-list file-list) |
|---|
| 447 |
(put 'reftex-global-search :regexp regexp) |
|---|
| 448 |
(move-marker reftex-global-search-marker nil) |
|---|
| 449 |
(reftex-global-search-continue)) |
|---|
| 450 |
|
|---|
| 451 |
(defun reftex-global-search-continue () |
|---|
| 452 |
|
|---|
| 453 |
(unless (get 'reftex-global-search :file-list) |
|---|
| 454 |
(error "No global search to continue")) |
|---|
| 455 |
(let* ((file-list (get 'reftex-global-search :file-list)) |
|---|
| 456 |
(regexp (get 'reftex-global-search :regexp)) |
|---|
| 457 |
(buf (or (marker-buffer reftex-global-search-marker) |
|---|
| 458 |
(reftex-get-file-buffer-force (car file-list)))) |
|---|
| 459 |
(pos (or (marker-position reftex-global-search-marker) 1)) |
|---|
| 460 |
file) |
|---|
| 461 |
|
|---|
| 462 |
(unless buf (error "No such buffer %s" buf)) |
|---|
| 463 |
(switch-to-buffer buf) |
|---|
| 464 |
(widen) |
|---|
| 465 |
(goto-char pos) |
|---|
| 466 |
|
|---|
| 467 |
(if (catch 'exit |
|---|
| 468 |
(while t |
|---|
| 469 |
(when (re-search-forward regexp nil t) |
|---|
| 470 |
(move-marker reftex-global-search-marker (point)) |
|---|
| 471 |
(throw 'exit t)) |
|---|
| 472 |
|
|---|
| 473 |
(pop file-list) |
|---|
| 474 |
(or file-list (throw 'exit nil)) |
|---|
| 475 |
(setq file (car file-list) |
|---|
| 476 |
buf (reftex-get-file-buffer-force file)) |
|---|
| 477 |
(unless buf (error "Cannot access file %s" file)) |
|---|
| 478 |
(put 'reftex-global-search :file-list file-list) |
|---|
| 479 |
(switch-to-buffer buf) |
|---|
| 480 |
(widen) |
|---|
| 481 |
(goto-char 1))) |
|---|
| 482 |
t |
|---|
| 483 |
(move-marker reftex-global-search-marker nil) |
|---|
| 484 |
(error "All files processed")))) |
|---|
| 485 |
|
|---|
| 486 |
|
|---|
| 487 |
|
|---|
| 488 |
|
|---|