Mercurial > emacs
annotate lisp/textmodes/reftex-dcr.el @ 88155:d7ddb3e565de
sync with trunk
author | Henrik Enberg <henrik.enberg@telia.com> |
---|---|
date | Mon, 16 Jan 2006 00:03:54 +0000 |
parents | 5ade352e8d1c |
children |
rev | line source |
---|---|
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
37998
diff
changeset
|
1 ;;; reftex-dcr.el --- viewing cross references and citations with RefTeX |
88155 | 2 ;; Copyright (c) 1997, 1998, 1999, 2000, 2003, 2004, 2005 |
3 ;; Free Software Foundation, Inc. | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
4 |
46612
7522419c4db0
Updated to reftex 4.17
Carsten Dominik <dominik@science.uva.nl>
parents:
38422
diff
changeset
|
5 ;; Author: Carsten Dominik <dominik@science.uva.nl> |
88155 | 6 ;; Version: VERSIONTAG |
27192
f70a80cecdd3
New version number.
Carsten Dominik <dominik@science.uva.nl>
parents:
27170
diff
changeset
|
7 ;; |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
8 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
9 ;; This file is part of GNU Emacs. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
10 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
11 ;; GNU Emacs is free software; you can redistribute it and/or modify |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
12 ;; it under the terms of the GNU General Public License as published by |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
13 ;; the Free Software Foundation; either version 2, or (at your option) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
14 ;; any later version. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
15 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
19 ;; GNU General Public License for more details. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
20 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
88155 | 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 ;; Boston, MA 02110-1301, USA. | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
25 |
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
37998
diff
changeset
|
26 ;;; Commentary: |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
37998
diff
changeset
|
27 |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
37998
diff
changeset
|
28 ;;; Code: |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
37998
diff
changeset
|
29 |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
30 (eval-when-compile (require 'cl)) |
27192
f70a80cecdd3
New version number.
Carsten Dominik <dominik@science.uva.nl>
parents:
27170
diff
changeset
|
31 (provide 'reftex-dcr) |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
32 (provide 'reftex-vcr) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
33 (require 'reftex) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
34 ;;; |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
35 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
36 (defun reftex-view-crossref (&optional arg auto-how) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
37 "View cross reference of macro at point. Point must be on the KEY |
36877
701567828afa
(reftex-view-crossref): Doc fix.
Andreas Schwab <schwab@suse.de>
parents:
34707
diff
changeset
|
38 argument. When at at `\\ref' macro, show corresponding `\\label' |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
39 definition, also in external documents (`xr'). When on a label, show |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
40 a locations where KEY is referenced. Subsequent calls find additional |
36877
701567828afa
(reftex-view-crossref): Doc fix.
Andreas Schwab <schwab@suse.de>
parents:
34707
diff
changeset
|
41 locations. When on a `\\cite', show the associated `\\bibitem' macro or |
701567828afa
(reftex-view-crossref): Doc fix.
Andreas Schwab <schwab@suse.de>
parents:
34707
diff
changeset
|
42 the BibTeX database entry. When on a `\\bibitem', show a `\\cite' macro |
701567828afa
(reftex-view-crossref): Doc fix.
Andreas Schwab <schwab@suse.de>
parents:
34707
diff
changeset
|
43 which uses this KEY. When on an `\\index', show other locations marked |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
44 by the same index entry. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
45 To define additional cross referencing items, use the option |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
46 `reftex-view-crossref-extra'. See also `reftex-view-crossref-from-bibtex'. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
47 With one or two C-u prefixes, enforce rescanning of the document. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
48 With argument 2, select the window showing the cross reference. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
49 AUTO-HOW is only for the automatic crossref display and is handed through |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
50 to the functions `reftex-view-cr-cite' and `reftex-view-cr-ref'." |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
51 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
52 (interactive "P") |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
53 ;; See where we are. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
54 (let* ((macro (car (reftex-what-macro-safe 1))) |
34707
315a42c87d8d
(reftex-view-crossref): added SPACE and TAB as key separators.
Carsten Dominik <dominik@science.uva.nl>
parents:
34402
diff
changeset
|
55 (key (reftex-this-word "^{}%\n\r, \t")) |
88155 | 56 dw) |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
57 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
58 (if (or (null macro) (reftex-in-comment)) |
88155 | 59 (error "Not on a crossref macro argument")) |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
60 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
61 (setq reftex-call-back-to-this-buffer (current-buffer)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
62 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
63 (cond |
29775
31536c6cf2e3
* textmodes/reftex.el (reftex-find-citation-regexp-format):
Carsten Dominik <dominik@science.uva.nl>
parents:
27604
diff
changeset
|
64 ((string-match "\\`\\\\cite\\|cite\\*?\\'\\|bibentry" macro) |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
65 ;; A citation macro: search for bibitems or BibTeX entries |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
66 (setq dw (reftex-view-cr-cite arg key auto-how))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
67 ((string-match "\\`\\\\ref\\|ref\\(range\\)?\\*?\\'" macro) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
68 ;; A reference macro: search for labels |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
69 (setq dw (reftex-view-cr-ref arg key auto-how))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
70 (auto-how nil) ;; No further action for automatic display (speed) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
71 ((or (equal macro "\\label") |
88155 | 72 (member macro reftex-macros-with-labels)) |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
73 ;; A label macro: search for reference macros |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
74 (reftex-access-scan-info arg) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
75 (setq dw (reftex-view-regexp-match |
88155 | 76 (format reftex-find-reference-format (regexp-quote key)) |
77 4 nil nil))) | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
78 ((equal macro "\\bibitem") |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
79 ;; A bibitem macro: search for citations |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
80 (reftex-access-scan-info arg) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
81 (setq dw (reftex-view-regexp-match |
88155 | 82 (format reftex-find-citation-regexp-format (regexp-quote key)) |
83 4 nil nil))) | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
84 ((member macro reftex-macros-with-index) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
85 (reftex-access-scan-info arg) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
86 (setq dw (reftex-view-regexp-match |
88155 | 87 (format reftex-find-index-entry-regexp-format |
88 (regexp-quote key)) | |
89 3 nil nil))) | |
90 (t | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
91 (reftex-access-scan-info arg) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
92 (catch 'exit |
88155 | 93 (let ((list reftex-view-crossref-extra) |
94 entry mre action group) | |
95 (while (setq entry (pop list)) | |
96 (setq mre (car entry) | |
97 action (nth 1 entry) | |
98 group (nth 2 entry)) | |
99 (when (string-match mre macro) | |
100 (setq dw (reftex-view-regexp-match | |
101 (format action key) group nil nil)) | |
102 (throw 'exit t)))) | |
103 (error "Not on a crossref macro argument")))) | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
104 (if (and (eq arg 2) (windowp dw)) (select-window dw)))) |
88155 | 105 |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
106 (defun reftex-view-cr-cite (arg key how) |
88155 | 107 ;; View crossreference of a ref cite. HOW can have the values |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
108 ;; nil: Show in another window. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
109 ;; echo: Show one-line info in echo area. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
110 ;; tmp-window: Show in small window and arrange for window to disappear. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
111 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
112 ;; Ensure access to scanning info |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
113 (reftex-access-scan-info (or arg current-prefix-arg)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
114 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
115 (if (eq how 'tmp-window) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
116 ;; Remember the window configuration |
88155 | 117 (put 'reftex-auto-view-crossref 'last-window-conf |
118 (current-window-configuration))) | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
119 |
46973
11e08f9901ea
Update to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
120 (let (files size item (pos (point)) (win (selected-window)) pop-win |
88155 | 121 (bibtype (reftex-bib-or-thebib))) |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
122 ;; Find the citation mode and the file list |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
123 (cond |
46973
11e08f9901ea
Update to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
124 ; ((assq 'bib (symbol-value reftex-docstruct-symbol)) |
11e08f9901ea
Update to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
125 ((eq bibtype 'bib) |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
126 (setq item nil |
88155 | 127 files (reftex-get-bibfile-list))) |
46973
11e08f9901ea
Update to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
128 ; ((assq 'thebib (symbol-value reftex-docstruct-symbol)) |
11e08f9901ea
Update to RefTeX 4.18
Carsten Dominik <dominik@science.uva.nl>
parents:
46683
diff
changeset
|
129 ((eq bibtype 'thebib) |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
130 (setq item t |
88155 | 131 files (reftex-uniquify |
132 (mapcar 'cdr | |
133 (reftex-all-assq | |
134 'thebib (symbol-value reftex-docstruct-symbol)))))) | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
135 (reftex-default-bibliography |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
136 (setq item nil |
88155 | 137 files (reftex-default-bibliography))) |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
138 (how) ;; don't throw for special display |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
139 (t (error "Cannot display crossref"))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
140 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
141 (if (eq how 'echo) |
88155 | 142 ;; Display in Echo area |
143 (reftex-echo-cite key files item) | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
144 ;; Display in a window |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
145 (if (not (eq how 'tmp-window)) |
88155 | 146 ;; Normal display |
147 (reftex-pop-to-bibtex-entry key files nil t item) | |
148 ;; A temporary window | |
149 (condition-case nil | |
150 (reftex-pop-to-bibtex-entry key files nil t item) | |
151 (error (goto-char pos) | |
152 (message "cite: no such citation key %s" key) | |
153 (error ""))) | |
154 ;; Resize the window | |
155 (setq size (max 1 (count-lines (point) | |
156 (reftex-end-of-bib-entry item)))) | |
157 (let ((window-min-height 2)) | |
158 (shrink-window (1- (- (window-height) size))) | |
159 (recenter 0)) | |
160 ;; Arrange restoration | |
161 (add-hook 'pre-command-hook 'reftex-restore-window-conf)) | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
162 |
88155 | 163 ;; Normal display in other window |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
164 (add-hook 'pre-command-hook 'reftex-highlight-shall-die) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
165 (setq pop-win (selected-window)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
166 (select-window win) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
167 (goto-char pos) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
168 (when (equal arg 2) |
88155 | 169 (select-window pop-win))))) |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
170 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
171 (defun reftex-view-cr-ref (arg label how) |
88155 | 172 ;; View crossreference of a ref macro. HOW can have the values |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
173 ;; nil: Show in another window. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
174 ;; echo: Show one-line info in echo area. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
175 ;; tmp-window: Show in small window and arrange for window to disappear. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
176 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
177 ;; Ensure access to scanning info |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
178 (reftex-access-scan-info (or arg current-prefix-arg)) |
88155 | 179 |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
180 (if (eq how 'tmp-window) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
181 ;; Remember the window configuration |
88155 | 182 (put 'reftex-auto-view-crossref 'last-window-conf |
183 (current-window-configuration))) | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
184 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
185 (let* ((xr-data (assoc 'xr (symbol-value reftex-docstruct-symbol))) |
88155 | 186 (xr-re (nth 2 xr-data)) |
187 (entry (assoc label (symbol-value reftex-docstruct-symbol))) | |
188 (win (selected-window)) pop-win (pos (point))) | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
189 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
190 (if (and (not entry) (stringp label) xr-re (string-match xr-re label)) |
88155 | 191 ;; Label is defined in external document |
192 (save-excursion | |
193 (save-match-data | |
194 (set-buffer | |
195 (or (reftex-get-file-buffer-force | |
196 (cdr (assoc (match-string 1 label) (nth 1 | |
197 xr-data)))) | |
198 (error "Problem with external label %s" label)))) | |
199 (setq label (substring label (match-end 1))) | |
200 (reftex-access-scan-info) | |
201 (setq entry | |
202 (assoc label (symbol-value reftex-docstruct-symbol))))) | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
203 (if (eq how 'echo) |
88155 | 204 ;; Display in echo area |
205 (reftex-echo-ref label entry (symbol-value reftex-docstruct-symbol)) | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
206 (let ((window-conf (current-window-configuration))) |
88155 | 207 (condition-case nil |
208 (reftex-show-label-location entry t nil t t) | |
209 (error (set-window-configuration window-conf) | |
210 (message "ref: Label %s not found" label) | |
211 (error "ref: Label %s not found" label)))) ;; 2nd is line OK | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
212 (add-hook 'pre-command-hook 'reftex-highlight-shall-die) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
213 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
214 (when (eq how 'tmp-window) |
88155 | 215 ;; Resize window and arrange restauration |
216 (shrink-window (1- (- (window-height) 9))) | |
217 (recenter '(4)) | |
218 (add-hook 'pre-command-hook 'reftex-restore-window-conf)) | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
219 (setq pop-win (selected-window)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
220 (select-window win) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
221 (goto-char pos) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
222 (when (equal arg 2) |
88155 | 223 (select-window pop-win))))) |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
224 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
225 (defun reftex-mouse-view-crossref (ev) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
226 "View cross reference of \\ref or \\cite macro where you click. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
227 If the macro at point is a \\ref, show the corresponding label definition. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
228 If it is a \\cite, show the BibTeX database entry. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
229 If there is no such macro at point, search forward to find one. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
230 With argument, actually select the window showing the cross reference." |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
231 (interactive "e") |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
232 (mouse-set-point ev) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
233 (reftex-view-crossref current-prefix-arg)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
234 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
235 (defun reftex-view-crossref-when-idle () |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
236 ;; Display info about crossref at point in echo area or a window. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
237 ;; This function was desigend to work with an idle timer. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
238 ;; We try to get out of here as quickly as possible if the call is useless. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
239 (and reftex-mode |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
240 ;; Make sure message area is free if we need it. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
241 (or (eq reftex-auto-view-crossref 'window) (not (current-message))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
242 ;; Make sure we are not already displaying this one |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
243 (not (memq last-command '(reftex-view-crossref |
88155 | 244 reftex-mouse-view-crossref))) |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
245 ;; Quick precheck if this might be a relevant spot |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
246 ;; FIXME: Can fail with backslash in comment |
88155 | 247 (save-excursion |
248 (search-backward "\\" nil t) | |
249 (looking-at "\\\\[a-zA-Z]*\\(cite\\|ref\\|bibentry\\)")) | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
250 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
251 (condition-case nil |
88155 | 252 (let ((current-prefix-arg nil)) |
253 (cond | |
254 ((eq reftex-auto-view-crossref t) | |
255 (reftex-view-crossref -1 'echo)) | |
256 ((eq reftex-auto-view-crossref 'window) | |
257 (reftex-view-crossref -1 'tmp-window)) | |
258 (t nil))) | |
259 (error nil)))) | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
260 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
261 (defun reftex-restore-window-conf () |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
262 (set-window-configuration (get 'reftex-auto-view-crossref 'last-window-conf)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
263 (put 'reftex-auto-view-crossref 'last-window-conf nil) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
264 (remove-hook 'pre-command-hook 'reftex-restore-window-conf)) |
88155 | 265 |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
266 (defun reftex-echo-ref (label entry docstruct) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
267 ;; Display crossref info in echo area. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
268 (cond |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
269 ((null docstruct) |
88155 | 270 (message "%s" (substitute-command-keys (format reftex-no-info-message "ref")))) |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
271 ((null entry) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
272 (message "ref: unknown label: %s" label)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
273 (t |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
274 (when (stringp (nth 2 entry)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
275 (message "ref(%s): %s" (nth 1 entry) (nth 2 entry))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
276 (let ((buf (get-buffer " *Echo Area*"))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
277 (when buf |
88155 | 278 (save-excursion |
279 (set-buffer buf) | |
280 (run-hooks 'reftex-display-copied-context-hook))))))) | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
281 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
282 (defun reftex-echo-cite (key files item) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
283 ;; Display citation info in echo area. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
284 (let* ((cache (assq 'bibview-cache (symbol-value reftex-docstruct-symbol))) |
88155 | 285 (cache-entry (assoc key (cdr cache))) |
286 entry string buf (all-files files)) | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
287 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
288 (if (and reftex-cache-cite-echo cache-entry) |
88155 | 289 ;; We can just use the cache |
290 (setq string (cdr cache-entry)) | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
291 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
292 ;; Need to look in the database |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
293 (unless reftex-revisit-to-echo |
88155 | 294 (setq files (reftex-visited-files files))) |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
295 |
88155 | 296 (setq entry |
297 (condition-case nil | |
298 (save-excursion | |
299 (reftex-pop-to-bibtex-entry key files nil nil item t)) | |
300 (error | |
301 (if (and files (= (length all-files) (length files))) | |
302 (message "cite: no such database entry: %s" key) | |
303 (message "%s" (substitute-command-keys | |
304 (format reftex-no-info-message "cite")))) | |
305 nil))) | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
306 (when entry |
88155 | 307 (if item |
308 (setq string (reftex-nicify-text entry)) | |
309 (setq string (reftex-make-cite-echo-string | |
310 (reftex-parse-bibtex-entry entry) | |
311 reftex-docstruct-symbol))))) | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
312 (unless (or (null string) (equal string "")) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
313 (message "cite: %s" string)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
314 (when (setq buf (get-buffer " *Echo Area*")) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
315 (save-excursion |
88155 | 316 (set-buffer buf) |
317 (run-hooks 'reftex-display-copied-context-hook))))) | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
318 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
319 (defvar reftex-use-itimer-in-xemacs nil |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
320 "*Non-nil means use the idle timers in XEmacs for crossref display. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
321 Currently, idle timer restart is broken and we use the post-command-hook.") |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
322 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
323 (defun reftex-toggle-auto-view-crossref () |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
324 "Toggle the automatic display of crossref information in the echo area. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
325 When active, leaving point idle in the argument of a \\ref or \\cite macro |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
326 will display info in the echo area." |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
327 (interactive) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
328 (if reftex-auto-view-crossref-timer |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
329 (progn |
88155 | 330 (if (featurep 'xemacs) |
331 (if reftex-use-itimer-in-xemacs | |
332 (delete-itimer reftex-auto-view-crossref-timer) | |
333 (remove-hook 'post-command-hook 'reftex-start-itimer-once)) | |
334 (cancel-timer reftex-auto-view-crossref-timer)) | |
335 (setq reftex-auto-view-crossref-timer nil) | |
336 (message "Automatic display of crossref information was turned off")) | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
337 (setq reftex-auto-view-crossref-timer |
88155 | 338 (if (featurep 'xemacs) |
339 (if reftex-use-itimer-in-xemacs | |
340 (start-itimer "RefTeX Idle Timer" | |
341 'reftex-view-crossref-when-idle | |
342 reftex-idle-time reftex-idle-time t) | |
343 (add-hook 'post-command-hook 'reftex-start-itimer-once) | |
344 t) | |
345 (run-with-idle-timer | |
346 reftex-idle-time t 'reftex-view-crossref-when-idle))) | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
347 (unless reftex-auto-view-crossref |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
348 (setq reftex-auto-view-crossref t)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
349 (message "Automatic display of crossref information was turned on"))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
350 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
351 (defun reftex-start-itimer-once () |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
352 (and reftex-mode |
88155 | 353 (not (itimer-live-p reftex-auto-view-crossref-timer)) |
354 (setq reftex-auto-view-crossref-timer | |
355 (start-itimer "RefTeX Idle Timer" | |
356 'reftex-view-crossref-when-idle | |
357 reftex-idle-time nil t)))) | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
358 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
359 (defun reftex-view-crossref-from-bibtex (&optional arg) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
360 "View location in a LaTeX document which cites the BibTeX entry at point. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
361 Since BibTeX files can be used by many LaTeX documents, this function |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
362 prompts upon first use for a buffer in RefTeX mode. To reset this |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
363 link to a document, call the function with with a prefix arg. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
364 Calling this function several times find successive citation locations." |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
365 (interactive "P") |
88155 | 366 (when arg |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
367 ;; Break connection to reference buffer |
29775
31536c6cf2e3
* textmodes/reftex.el (reftex-find-citation-regexp-format):
Carsten Dominik <dominik@science.uva.nl>
parents:
27604
diff
changeset
|
368 (put 'reftex-bibtex-view-cite-locations :ref-buffer nil)) |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
369 (let ((ref-buffer (get 'reftex-bibtex-view-cite-locations :ref-buffer))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
370 ;; Establish connection to reference buffer |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
371 (unless ref-buffer |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
372 (setq ref-buffer |
88155 | 373 (save-excursion |
374 (completing-read | |
375 "Reference buffer: " | |
376 (delq nil | |
377 (mapcar | |
378 (lambda (b) | |
379 (set-buffer b) | |
380 (if reftex-mode (list (buffer-name b)) nil)) | |
381 (buffer-list))) | |
382 nil t))) | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
383 (put 'reftex-bibtex-view-cite-locations :ref-buffer ref-buffer)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
384 ;; Search for citations |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
385 (bibtex-beginning-of-entry) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
386 (if (looking-at |
88155 | 387 "@[a-zA-Z]+[ \t\n\r]*[{(][ \t\n\r]*\\([^, \t\r\n}]+\\)") |
388 (progn | |
389 (goto-char (match-beginning 1)) | |
390 (reftex-view-regexp-match | |
391 (format reftex-find-citation-regexp-format | |
392 (regexp-quote (match-string 1))) | |
393 4 arg ref-buffer)) | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
394 (error "Cannot find citation key in BibTeX entry")))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
395 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
396 (defun reftex-view-regexp-match (re &optional highlight-group new ref-buffer) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
397 ;; Search for RE in current document or in the document of REF-BUFFER. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
398 ;; Continue the search, if the same re was searched last. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
399 ;; Highlight the group HIGHLIGHT-GROUP of the match. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
400 ;; When NEW is non-nil, start a new search regardless. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
401 ;; Match point is displayed in another window. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
402 ;; Upon success, returns the window which displays the match. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
403 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
404 ;;; Decide if new search or continued search |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
405 (let* ((oldprop (get 'reftex-view-regexp-match :props)) |
88155 | 406 (newprop (list (current-buffer) re)) |
407 (cont (and (not new) (equal oldprop newprop))) | |
408 (cnt (if cont (get 'reftex-view-regexp-match :cnt) 0)) | |
409 (current-window (selected-window)) | |
410 (window-conf (current-window-configuration)) | |
411 match pop-window) | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
412 (switch-to-buffer-other-window (or ref-buffer (current-buffer))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
413 ;; Search |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
414 (condition-case nil |
88155 | 415 (if cont |
416 (setq match (reftex-global-search-continue)) | |
417 (reftex-access-scan-info) | |
418 (setq match (reftex-global-search re (reftex-all-document-files)))) | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
419 (error nil)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
420 ;; Evaluate the match. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
421 (if match |
88155 | 422 (progn |
423 (put 'reftex-view-regexp-match :props newprop) | |
424 (put 'reftex-view-regexp-match :cnt (incf cnt)) | |
425 (reftex-highlight 0 (match-beginning highlight-group) | |
426 (match-end highlight-group)) | |
427 (add-hook 'pre-command-hook 'reftex-highlight-shall-die) | |
428 (setq pop-window (selected-window))) | |
29775
31536c6cf2e3
* textmodes/reftex.el (reftex-find-citation-regexp-format):
Carsten Dominik <dominik@science.uva.nl>
parents:
27604
diff
changeset
|
429 (put 'reftex-view-regexp-match :props nil) |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
430 (or cont (set-window-configuration window-conf))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
431 (select-window current-window) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
432 (if match |
88155 | 433 (progn |
434 (message "Match Nr. %s" cnt) | |
435 pop-window) | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
436 (if cont |
88155 | 437 (error "No further matches (total number of matches: %d)" cnt) |
438 (error "No matches"))))) | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
439 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
440 (defvar reftex-global-search-marker (make-marker)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
441 (defun reftex-global-search (regexp file-list) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
442 ;; Start a search for REGEXP in all files of FILE-LIST |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
443 (put 'reftex-global-search :file-list file-list) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
444 (put 'reftex-global-search :regexp regexp) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
445 (move-marker reftex-global-search-marker nil) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
446 (reftex-global-search-continue)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
447 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
448 (defun reftex-global-search-continue () |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
449 ;; Continue a global search started with `reftex-global-search' |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
450 (unless (get 'reftex-global-search :file-list) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
451 (error "No global search to continue")) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
452 (let* ((file-list (get 'reftex-global-search :file-list)) |
88155 | 453 (regexp (get 'reftex-global-search :regexp)) |
454 (buf (or (marker-buffer reftex-global-search-marker) | |
455 (reftex-get-file-buffer-force (car file-list)))) | |
456 (pos (or (marker-position reftex-global-search-marker) 1)) | |
457 file) | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
458 ;; Take up starting position |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
459 (unless buf (error "No such buffer %s" buf)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
460 (switch-to-buffer buf) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
461 (widen) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
462 (goto-char pos) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
463 ;; Search and switch file if necessary |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
464 (if (catch 'exit |
88155 | 465 (while t |
466 (when (re-search-forward regexp nil t) | |
467 (move-marker reftex-global-search-marker (point)) | |
468 (throw 'exit t)) | |
469 ;; No match - goto next file | |
470 (pop file-list) | |
471 (or file-list (throw 'exit nil)) | |
472 (setq file (car file-list) | |
473 buf (reftex-get-file-buffer-force file)) | |
474 (unless buf (error "Cannot access file %s" file)) | |
475 (put 'reftex-global-search :file-list file-list) | |
476 (switch-to-buffer buf) | |
477 (widen) | |
478 (goto-char 1))) | |
479 t | |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
480 (move-marker reftex-global-search-marker nil) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
481 (error "All files processed")))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
482 |
88155 | 483 ;;; arch-tag: d2f52b56-744e-44ad-830d-1fc193b90eda |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
484 ;;; reftex-dcr.el ends here |