Mercurial > emacs
annotate lisp/textmodes/reftex-dcr.el @ 45436:0d9c23804094
(describe-char-after): Order display of text properties by the size of
their value, for clarity.
author | Colin Walters <walters@gnu.org> |
---|---|
date | Tue, 21 May 2002 06:05:39 +0000 |
parents | 7a94f1c588c4 |
children | 7522419c4db0 |
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 |
27192
f70a80cecdd3
New version number.
Carsten Dominik <dominik@science.uva.nl>
parents:
27170
diff
changeset
|
2 ;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
3 |
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
37998
diff
changeset
|
4 ;; Author: Carsten Dominik <dominik@strw.LeidenUniv.nl> |
37998
706af946b1e7
* reftex-ref.el (reftex-select-label-help): Added "z" key
Carsten Dominik <dominik@science.uva.nl>
parents:
36877
diff
changeset
|
5 ;; Version: 4.16 |
27192
f70a80cecdd3
New version number.
Carsten Dominik <dominik@science.uva.nl>
parents:
27170
diff
changeset
|
6 ;; |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
7 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
8 ;; 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
|
9 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
10 ;; 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
|
11 ;; 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
|
12 ;; 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
|
13 ;; any later version. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
14 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
15 ;; 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
|
16 ;; 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
|
17 ;; 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
|
18 ;; 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
|
19 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
20 ;; 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
|
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
23 ;; Boston, MA 02111-1307, USA. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
24 |
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
37998
diff
changeset
|
25 ;;; Commentary: |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
37998
diff
changeset
|
26 |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
37998
diff
changeset
|
27 ;;; Code: |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
37998
diff
changeset
|
28 |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
29 (eval-when-compile (require 'cl)) |
27192
f70a80cecdd3
New version number.
Carsten Dominik <dominik@science.uva.nl>
parents:
27170
diff
changeset
|
30 (provide 'reftex-dcr) |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
31 (provide 'reftex-vcr) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
32 (require 'reftex) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
33 ;;; |
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 (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
|
36 "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
|
37 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
|
38 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
|
39 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
|
40 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
|
41 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
|
42 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
|
43 by the same index entry. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
44 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
|
45 `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
|
46 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
|
47 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
|
48 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
|
49 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
|
50 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
51 (interactive "P") |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
52 ;; See where we are. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
53 (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
|
54 (key (reftex-this-word "^{}%\n\r, \t")) |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
55 dw) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
56 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
57 (if (or (null macro) (reftex-in-comment)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
58 (error "Not on a crossref macro argument")) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
59 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
60 (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
|
61 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
62 (cond |
29775
31536c6cf2e3
* textmodes/reftex.el (reftex-find-citation-regexp-format):
Carsten Dominik <dominik@science.uva.nl>
parents:
27604
diff
changeset
|
63 ((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
|
64 ;; 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
|
65 (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
|
66 ((string-match "\\`\\\\ref\\|ref\\(range\\)?\\*?\\'" macro) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
67 ;; A reference macro: search for labels |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
68 (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
|
69 (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
|
70 ((or (equal macro "\\label") |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
71 (member macro reftex-macros-with-labels)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
72 ;; 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
|
73 (reftex-access-scan-info arg) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
74 (setq dw (reftex-view-regexp-match |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
75 (format reftex-find-reference-format (regexp-quote key)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
76 4 nil nil))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
77 ((equal macro "\\bibitem") |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
78 ;; A bibitem macro: search for citations |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
79 (reftex-access-scan-info arg) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
80 (setq dw (reftex-view-regexp-match |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
81 (format reftex-find-citation-regexp-format (regexp-quote key)) |
29775
31536c6cf2e3
* textmodes/reftex.el (reftex-find-citation-regexp-format):
Carsten Dominik <dominik@science.uva.nl>
parents:
27604
diff
changeset
|
82 4 nil nil))) |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
83 ((member macro reftex-macros-with-index) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
84 (reftex-access-scan-info arg) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
85 (setq dw (reftex-view-regexp-match |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
86 (format reftex-find-index-entry-regexp-format |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
87 (regexp-quote key)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
88 3 nil nil))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
89 (t |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
90 (reftex-access-scan-info arg) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
91 (catch 'exit |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
92 (let ((list reftex-view-crossref-extra) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
93 entry mre action group) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
94 (while (setq entry (pop list)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
95 (setq mre (car entry) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
96 action (nth 1 entry) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
97 group (nth 2 entry)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
98 (when (string-match mre macro) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
99 (setq dw (reftex-view-regexp-match |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
100 (format action key) group nil nil)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
101 (throw 'exit t)))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
102 (error "Not on a crossref macro argument")))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
103 (if (and (eq arg 2) (windowp dw)) (select-window dw)))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
104 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
105 (defun reftex-view-cr-cite (arg key how) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
106 ;; View crossreference of a ref cite. HOW can have the values |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
107 ;; nil: Show in another window. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
108 ;; 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
|
109 ;; 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
|
110 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
111 ;; Ensure access to scanning info |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
112 (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
|
113 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
114 (if (eq how 'tmp-window) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
115 ;; Remember the window configuration |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
116 (put '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
|
117 (current-window-configuration))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
118 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
119 (let (files size item (pos (point)) (win (selected-window)) pop-win) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
120 ;; 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
|
121 (cond |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
122 ((assq 'bib (symbol-value reftex-docstruct-symbol)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
123 (setq item nil |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
124 files (reftex-get-bibfile-list))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
125 ((assq 'thebib (symbol-value reftex-docstruct-symbol)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
126 (setq item t |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
127 files (reftex-uniquify |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
128 (mapcar 'cdr |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
129 (reftex-all-assq |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
130 'thebib (symbol-value reftex-docstruct-symbol)))))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
131 (reftex-default-bibliography |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
132 (setq item nil |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
133 files (reftex-default-bibliography))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
134 (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
|
135 (t (error "Cannot display crossref"))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
136 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
137 (if (eq how 'echo) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
138 ;; Display in Echo area |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
139 (reftex-echo-cite key files item) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
140 ;; Display in a window |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
141 (if (not (eq how 'tmp-window)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
142 ;; Normal display |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
143 (reftex-pop-to-bibtex-entry key files nil t item) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
144 ;; A temporary window |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
145 (condition-case nil |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
146 (reftex-pop-to-bibtex-entry key files nil t item) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
147 (error (goto-char pos) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
148 (message "cite: no such citation key %s" key) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
149 (error ""))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
150 ;; Resize the window |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
151 (setq size (max 1 (count-lines (point) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
152 (reftex-end-of-bib-entry item)))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
153 (let ((window-min-height 2)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
154 (shrink-window (1- (- (window-height) size))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
155 (recenter 0)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
156 ;; Arrange restoration |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
157 (add-hook 'pre-command-hook 'reftex-restore-window-conf)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
158 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
159 ;; Normal display in other window |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
160 (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
|
161 (setq pop-win (selected-window)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
162 (select-window win) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
163 (goto-char pos) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
164 (when (equal arg 2) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
165 (select-window pop-win))))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
166 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
167 (defun reftex-view-cr-ref (arg label how) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
168 ;; View crossreference of a ref macro. HOW can have the values |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
169 ;; nil: Show in another window. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
170 ;; 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
|
171 ;; 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
|
172 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
173 ;; Ensure access to scanning info |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
174 (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
|
175 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
176 (if (eq how 'tmp-window) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
177 ;; Remember the window configuration |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
178 (put '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
|
179 (current-window-configuration))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
180 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
181 (let* ((xr-data (assoc 'xr (symbol-value reftex-docstruct-symbol))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
182 (xr-re (nth 2 xr-data)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
183 (entry (assoc label (symbol-value reftex-docstruct-symbol))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
184 (win (selected-window)) pop-win (pos (point))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
185 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
186 (if (and (not entry) (stringp label) xr-re (string-match xr-re label)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
187 ;; Label is defined in external document |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
188 (save-excursion |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
189 (save-match-data |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
190 (set-buffer |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
191 (or (reftex-get-file-buffer-force |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
192 (cdr (assoc (match-string 1 label) (nth 1 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
193 xr-data)))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
194 (error "Problem with external label %s" label)))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
195 (setq label (substring label (match-end 1))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
196 (reftex-access-scan-info) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
197 (setq entry |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
198 (assoc label (symbol-value reftex-docstruct-symbol))))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
199 (if (eq how 'echo) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
200 ;; Display in echo area |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
201 (reftex-echo-ref label entry (symbol-value reftex-docstruct-symbol)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
202 (let ((window-conf (current-window-configuration))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
203 (condition-case nil |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
204 (reftex-show-label-location entry t nil t t) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
205 (error (set-window-configuration window-conf) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
206 (message "ref: Label %s not found" label) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
207 (error "ref: Label %s not found" label)))) ;; 2nd is line OK |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
208 (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
|
209 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
210 (when (eq how 'tmp-window) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
211 ;; Resize window and arrange restauration |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
212 (shrink-window (1- (- (window-height) 9))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
213 (recenter '(4)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
214 (add-hook 'pre-command-hook 'reftex-restore-window-conf)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
215 (setq pop-win (selected-window)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
216 (select-window win) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
217 (goto-char pos) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
218 (when (equal arg 2) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
219 (select-window pop-win))))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
220 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
221 (defun reftex-mouse-view-crossref (ev) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
222 "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
|
223 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
|
224 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
|
225 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
|
226 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
|
227 (interactive "e") |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
228 (mouse-set-point ev) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
229 (reftex-view-crossref current-prefix-arg)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
230 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
231 (defun reftex-view-crossref-when-idle () |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
232 ;; 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
|
233 ;; 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
|
234 ;; 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
|
235 (and reftex-mode |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
236 ;; 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
|
237 (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
|
238 ;; 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
|
239 (not (memq last-command '(reftex-view-crossref |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
240 reftex-mouse-view-crossref))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
241 ;; 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
|
242 ;; FIXME: Can fail with backslash in comment |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
243 (save-excursion |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
244 (search-backward "\\" nil t) |
29775
31536c6cf2e3
* textmodes/reftex.el (reftex-find-citation-regexp-format):
Carsten Dominik <dominik@science.uva.nl>
parents:
27604
diff
changeset
|
245 (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
|
246 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
247 (condition-case nil |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
248 (let ((current-prefix-arg nil)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
249 (cond |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
250 ((eq reftex-auto-view-crossref t) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
251 (reftex-view-crossref -1 'echo)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
252 ((eq reftex-auto-view-crossref 'window) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
253 (reftex-view-crossref -1 'tmp-window)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
254 (t nil))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
255 (error nil)))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
256 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
257 (defun reftex-restore-window-conf () |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
258 (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
|
259 (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
|
260 (remove-hook 'pre-command-hook 'reftex-restore-window-conf)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
261 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
262 (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
|
263 ;; Display crossref info in echo area. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
264 (cond |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
265 ((null docstruct) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
266 (message (substitute-command-keys (format reftex-no-info-message "ref")))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
267 ((null entry) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
268 (message "ref: unknown label: %s" label)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
269 (t |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
270 (when (stringp (nth 2 entry)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
271 (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
|
272 (let ((buf (get-buffer " *Echo Area*"))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
273 (when buf |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
274 (save-excursion |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
275 (set-buffer buf) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
276 (run-hooks 'reftex-display-copied-context-hook))))))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
277 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
278 (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
|
279 ;; Display citation info in echo area. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
280 (let* ((cache (assq 'bibview-cache (symbol-value reftex-docstruct-symbol))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
281 (cache-entry (assoc key (cdr cache))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
282 entry string buf (all-files files)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
283 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
284 (if (and reftex-cache-cite-echo cache-entry) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
285 ;; We can just use the cache |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
286 (setq string (cdr cache-entry)) |
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 ;; Need to look in the database |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
289 (unless reftex-revisit-to-echo |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
290 (setq files (reftex-visited-files files))) |
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 (setq entry |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
293 (condition-case nil |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
294 (save-excursion |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
295 (reftex-pop-to-bibtex-entry key files nil nil item t)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
296 (error |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
297 (if (and files (= (length all-files) (length files))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
298 (message "cite: no such database entry: %s" key) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
299 (message (substitute-command-keys |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
300 (format reftex-no-info-message "cite")))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
301 nil))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
302 (when entry |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
303 (if item |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
304 (setq string (reftex-nicify-text entry)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
305 (setq string (reftex-make-cite-echo-string |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
306 (reftex-parse-bibtex-entry entry) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
307 reftex-docstruct-symbol))))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
308 (unless (or (null string) (equal string "")) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
309 (message "cite: %s" string)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
310 (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
|
311 (save-excursion |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
312 (set-buffer buf) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
313 (run-hooks 'reftex-display-copied-context-hook))))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
314 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
315 (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
|
316 "*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
|
317 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
|
318 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
319 (defun reftex-toggle-auto-view-crossref () |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
320 "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
|
321 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
|
322 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
|
323 (interactive) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
324 (if reftex-auto-view-crossref-timer |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
325 (progn |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
326 (if (featurep 'xemacs) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
327 (if reftex-use-itimer-in-xemacs |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
328 (delete-itimer reftex-auto-view-crossref-timer) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
329 (remove-hook 'post-command-hook 'reftex-start-itimer-once)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
330 (cancel-timer reftex-auto-view-crossref-timer)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
331 (setq reftex-auto-view-crossref-timer nil) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
332 (message "Automatic display of crossref information was turned off")) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
333 (setq reftex-auto-view-crossref-timer |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
334 (if (featurep 'xemacs) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
335 (if reftex-use-itimer-in-xemacs |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
336 (start-itimer "RefTeX Idle Timer" |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
337 'reftex-view-crossref-when-idle |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
338 reftex-idle-time reftex-idle-time t) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
339 (add-hook 'post-command-hook 'reftex-start-itimer-once) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
340 t) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
341 (run-with-idle-timer |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
342 reftex-idle-time t 'reftex-view-crossref-when-idle))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
343 (unless reftex-auto-view-crossref |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
344 (setq reftex-auto-view-crossref t)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
345 (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
|
346 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
347 (defun reftex-start-itimer-once () |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
348 (and reftex-mode |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
349 (not (itimer-live-p reftex-auto-view-crossref-timer)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
350 (setq reftex-auto-view-crossref-timer |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
351 (start-itimer "RefTeX Idle Timer" |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
352 'reftex-view-crossref-when-idle |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
353 reftex-idle-time nil t)))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
354 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
355 (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
|
356 "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
|
357 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
|
358 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
|
359 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
|
360 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
|
361 (interactive "P") |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
362 (when arg |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
363 ;; 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
|
364 (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
|
365 (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
|
366 ;; Establish connection to reference buffer |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
367 (unless ref-buffer |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
368 (setq ref-buffer |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
369 (save-excursion |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
370 (completing-read |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
371 "Reference buffer: " |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
372 (delq nil |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
373 (mapcar |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
374 (lambda (b) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
375 (set-buffer b) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
376 (if reftex-mode (list (buffer-name b)) nil)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
377 (buffer-list))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
378 nil t))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
379 (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
|
380 ;; Search for citations |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
381 (bibtex-beginning-of-entry) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
382 (if (looking-at |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
383 "@[a-zA-Z]+[ \t\n\r]*[{(][ \t\n\r]*\\([^, \t\r\n}]+\\)") |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
384 (progn |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
385 (goto-char (match-beginning 1)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
386 (reftex-view-regexp-match |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
387 (format reftex-find-citation-regexp-format |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
388 (regexp-quote (match-string 1))) |
29775
31536c6cf2e3
* textmodes/reftex.el (reftex-find-citation-regexp-format):
Carsten Dominik <dominik@science.uva.nl>
parents:
27604
diff
changeset
|
389 4 arg ref-buffer)) |
27170
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
390 (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
|
391 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
392 (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
|
393 ;; 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
|
394 ;; 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
|
395 ;; 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
|
396 ;; 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
|
397 ;; 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
|
398 ;; 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
|
399 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
400 ;;; 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
|
401 (let* ((oldprop (get 'reftex-view-regexp-match :props)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
402 (newprop (list (current-buffer) re)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
403 (cont (and (not new) (equal oldprop newprop))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
404 (cnt (if cont (get 'reftex-view-regexp-match :cnt) 0)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
405 (current-window (selected-window)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
406 (window-conf (current-window-configuration)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
407 match pop-window) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
408 (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
|
409 ;; Search |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
410 (condition-case nil |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
411 (if cont |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
412 (setq match (reftex-global-search-continue)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
413 (reftex-access-scan-info) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
414 (setq match (reftex-global-search re (reftex-all-document-files)))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
415 (error nil)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
416 ;; Evaluate the match. |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
417 (if match |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
418 (progn |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
419 (put 'reftex-view-regexp-match :props newprop) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
420 (put 'reftex-view-regexp-match :cnt (incf cnt)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
421 (reftex-highlight 0 (match-beginning highlight-group) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
422 (match-end highlight-group)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
423 (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
|
424 (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
|
425 (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
|
426 (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
|
427 (select-window current-window) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
428 (if match |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
429 (progn |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
430 (message "Match Nr. %s" cnt) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
431 pop-window) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
432 (if cont |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
433 (error "No further matches (total number of matches: %d)" cnt) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
434 (error "No matches"))))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
435 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
436 (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
|
437 (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
|
438 ;; 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
|
439 (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
|
440 (put 'reftex-global-search :regexp regexp) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
441 (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
|
442 (reftex-global-search-continue)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
443 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
444 (defun reftex-global-search-continue () |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
445 ;; 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
|
446 (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
|
447 (error "No global search to continue")) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
448 (let* ((file-list (get 'reftex-global-search :file-list)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
449 (regexp (get 'reftex-global-search :regexp)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
450 (buf (or (marker-buffer reftex-global-search-marker) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
451 (reftex-get-file-buffer-force (car file-list)))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
452 (pos (or (marker-position reftex-global-search-marker) 1)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
453 file) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
454 ;; Take up starting position |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
455 (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
|
456 (switch-to-buffer buf) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
457 (widen) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
458 (goto-char pos) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
459 ;; Search and switch file if necessary |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
460 (if (catch 'exit |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
461 (while t |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
462 (when (re-search-forward regexp nil t) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
463 (move-marker reftex-global-search-marker (point)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
464 (throw 'exit t)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
465 ;; No match - goto next file |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
466 (pop file-list) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
467 (or file-list (throw 'exit nil)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
468 (setq file (car file-list) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
469 buf (reftex-get-file-buffer-force file)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
470 (unless buf (error "Cannot access file %s" file)) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
471 (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
|
472 (switch-to-buffer buf) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
473 (widen) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
474 (goto-char 1))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
475 t |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
476 (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
|
477 (error "All files processed")))) |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
478 |
3cba3e588544
renamed reftex-vcr.el to reftex-dcr.el
Carsten Dominik <dominik@science.uva.nl>
parents:
diff
changeset
|
479 ;;; reftex-dcr.el ends here |