diff options
| author | Carsten Dominik | 1998-09-07 07:28:16 +0000 |
|---|---|---|
| committer | Carsten Dominik | 1998-09-07 07:28:16 +0000 |
| commit | a6611c0d5674142e14069005c95d7ed9c638e4ec (patch) | |
| tree | 70241ed8fa6532b39d43eee003922c3adf48e6a3 | |
| parent | d166ae52eac0bf918160575d1f113745049d348c (diff) | |
| download | emacs-a6611c0d5674142e14069005c95d7ed9c638e4ec.tar.gz emacs-a6611c0d5674142e14069005c95d7ed9c638e4ec.zip | |
(reftex-view-crossref): Split up into several functions. No longer moves
to find a macro.
(reftex-view-cr-cite, reftex-view-cr-ref,
reftex-end-of-bib-entry): New functions.
(reftex-auto-view-crossref): New value `window' allowed.
(reftex-view-crossref-when-idle): Process new `window' option in
(reftex-translate-to-ascii-function): New default.
(reftex-label-illegal-re): Default changed, removed Latin1.
(reftex-latin1-to-ascii): New function.
(reftex-what-environment): Check for section regexp before use.
(reftex-find-tex-file, reftex-find-bib-file): Fixed bug with absolute
path names.
(reftex-TeX-master-file): Changed sequence of file checks.
(reftex-do-citation): bibview cache only with RefTeX mode on.
| -rw-r--r-- | lisp/textmodes/reftex.el | 474 |
1 files changed, 267 insertions, 207 deletions
diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el index e517900fb08..d3ab77812ac 100644 --- a/lisp/textmodes/reftex.el +++ b/lisp/textmodes/reftex.el | |||
| @@ -33,6 +33,13 @@ | |||
| 33 | ;; access to any part of a document. | 33 | ;; access to any part of a document. |
| 34 | ;; | 34 | ;; |
| 35 | ;; | 35 | ;; |
| 36 | ;; INSTALLATION | ||
| 37 | ;; ------------ | ||
| 38 | ;; | ||
| 39 | ;; If you got reftex.el with an Emacs distribution, it is already | ||
| 40 | ;; installed. If not, follow the instructions in the INSTALL file of | ||
| 41 | ;; the distribution. | ||
| 42 | ;; | ||
| 36 | ;; To turn RefTeX Mode on and off in a particular buffer, use | 43 | ;; To turn RefTeX Mode on and off in a particular buffer, use |
| 37 | ;; `M-x reftex-mode'. | 44 | ;; `M-x reftex-mode'. |
| 38 | ;; | 45 | ;; |
| @@ -46,12 +53,14 @@ | |||
| 46 | ;; DOCUMENTATION | 53 | ;; DOCUMENTATION |
| 47 | ;; ------------- | 54 | ;; ------------- |
| 48 | ;; | 55 | ;; |
| 56 | ;; See below for a short summary of how to use RefTeX. | ||
| 57 | ;; | ||
| 49 | ;; There is an extensive texinfo document describing RefTeX in detail. | 58 | ;; There is an extensive texinfo document describing RefTeX in detail. |
| 50 | ;; When you are getting reftex.el with the Emacs distribution, the | 59 | ;; When you are getting reftex.el with the Emacs distribution, the |
| 51 | ;; info files should already be installed. To view this | 60 | ;; info files should already be installed. To view this |
| 52 | ;; documentation, use `M-x reftex-info RET'. | 61 | ;; documentation, use `M-x reftex-info RET'. |
| 53 | ;; | 62 | ;; |
| 54 | ;; The documentation is also available at | 63 | ;; The documentation in various formats is also available at |
| 55 | ;; | 64 | ;; |
| 56 | ;; http://www.strw.leidenuniv.nl/~dominik/Tools/ | 65 | ;; http://www.strw.leidenuniv.nl/~dominik/Tools/ |
| 57 | ;; | 66 | ;; |
| @@ -64,7 +73,7 @@ | |||
| 64 | ;; RefTeX distinguishes labels for different environments. It knows | 73 | ;; RefTeX distinguishes labels for different environments. It knows |
| 65 | ;; about all standard environments (and many others), and can be | 74 | ;; about all standard environments (and many others), and can be |
| 66 | ;; configured to recognize any additional labeled environments you | 75 | ;; configured to recognize any additional labeled environments you |
| 67 | ;; have defined yourself (variable REFTEX-LABEL-ALIST(). | 76 | ;; have defined yourself (variable REFTEX-LABEL-ALIST). |
| 68 | ;; | 77 | ;; |
| 69 | ;; * Creating Labels | 78 | ;; * Creating Labels |
| 70 | ;; Type `C-c (' (`reftex-label') to insert a label at point. | 79 | ;; Type `C-c (' (`reftex-label') to insert a label at point. |
| @@ -96,7 +105,7 @@ | |||
| 96 | ;; When no other message occupies the echo area and point is idle on | 105 | ;; When no other message occupies the echo area and point is idle on |
| 97 | ;; the argument of a `\ref' or `\cite' macro, the echo area will | 106 | ;; the argument of a `\ref' or `\cite' macro, the echo area will |
| 98 | ;; display information about the citation/cross reference. | 107 | ;; display information about the citation/cross reference. |
| 99 | ;; With point on or anywhere before such a macro, press `C-c &' | 108 | ;; With point on the argument of such a macro, press `C-c &' |
| 100 | ;; (`reftex-view-crossref'), or click with `S-mouse-2' on the macro | 109 | ;; (`reftex-view-crossref'), or click with `S-mouse-2' on the macro |
| 101 | ;; argument. This will display the corresponding label definition or | 110 | ;; argument. This will display the corresponding label definition or |
| 102 | ;; BibTeX database entry in another window. | 111 | ;; BibTeX database entry in another window. |
| @@ -120,12 +129,14 @@ | |||
| 120 | ;; or press the `r' key in the label selection buffer or the table of | 129 | ;; or press the `r' key in the label selection buffer or the table of |
| 121 | ;; contents buffer. | 130 | ;; contents buffer. |
| 122 | ;; | 131 | ;; |
| 123 | ;; 7. Speed Issues | 132 | ;; 7. Useful Settings |
| 124 | ;; Useful settings to make RefTeX faster for large (multifile) | 133 | ;; To make RefTeX faster for large documents include, and to integrate |
| 125 | ;; documents include: | 134 | ;; it with AUCTeX, try these: |
| 135 | ;; | ||
| 126 | ;; (setq reftex-enable-partial-scans t) | 136 | ;; (setq reftex-enable-partial-scans t) |
| 127 | ;; (setq reftex-save-parse-info t) | 137 | ;; (setq reftex-save-parse-info t) |
| 128 | ;; (setq reftex-use-multiple-selection-buffers t) | 138 | ;; (setq reftex-use-multiple-selection-buffers t) |
| 139 | ;; (setq reftex-plug-into-AUCTeX t) | ||
| 129 | ;; | 140 | ;; |
| 130 | ;;--------------------------------------------------------------------------- | 141 | ;;--------------------------------------------------------------------------- |
| 131 | ;; | 142 | ;; |
| @@ -139,7 +150,7 @@ | |||
| 139 | ;; The newest version of RefTeX can be found at | 150 | ;; The newest version of RefTeX can be found at |
| 140 | ;; | 151 | ;; |
| 141 | ;; http://www.strw.leidenuniv.nl/~dominik/Tools/ | 152 | ;; http://www.strw.leidenuniv.nl/~dominik/Tools/ |
| 142 | ;; ftp://strw.leidenuniv.nl/pub/dominik/ | 153 | ;; ftp://ftp.strw.leidenuniv.nl/pub/dominik/ |
| 143 | ;; | 154 | ;; |
| 144 | ;; At that site you can also get version 3.22 of RefTeX which is still | 155 | ;; At that site you can also get version 3.22 of RefTeX which is still |
| 145 | ;; compatible with Emacs 19. The file you are reading now as well as the | 156 | ;; compatible with Emacs 19. The file you are reading now as well as the |
| @@ -154,14 +165,15 @@ | |||
| 154 | ;; Karl Eichwalder, Peter Galbraith, Dieter Kraft, Adrian Lanz, | 165 | ;; Karl Eichwalder, Peter Galbraith, Dieter Kraft, Adrian Lanz, |
| 155 | ;; Rory Molinari, Laurent Mugnier, Sudeep Kumar Palat, Daniel Polani, | 166 | ;; Rory Molinari, Laurent Mugnier, Sudeep Kumar Palat, Daniel Polani, |
| 156 | ;; Robin Socha, Richard Stanton, Allan Strand, Jan Vroonhof, | 167 | ;; Robin Socha, Richard Stanton, Allan Strand, Jan Vroonhof, |
| 157 | ;; Christoph Wedler. | 168 | ;; Christoph Wedler, Alan Williams. |
| 158 | ;; | 169 | ;; |
| 159 | ;; Finally thanks to Uwe Bolick who first got me (some years ago) into | 170 | ;; Finally thanks to Uwe Bolick who first got me (some years ago) into |
| 160 | ;; supporting LaTeX labels and references with an Editor (which was | 171 | ;; supporting LaTeX labels and references with an Editor (which was |
| 161 | ;; MicroEmacs at the time). | 172 | ;; MicroEmacs at the time). |
| 162 | ;; | 173 | ;; |
| 163 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 174 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 164 | ;; | 175 | ;; |
| 176 | ;;;;;; | ||
| 165 | 177 | ||
| 166 | ;;; Code: | 178 | ;;; Code: |
| 167 | 179 | ||
| @@ -628,12 +640,12 @@ RefTeX's default function uses the variable `reftex-derive-label-parameters'." | |||
| 628 | :group 'reftex-making-and-inserting-labels | 640 | :group 'reftex-making-and-inserting-labels |
| 629 | :type 'symbol) | 641 | :type 'symbol) |
| 630 | 642 | ||
| 631 | (defcustom reftex-translate-to-ascii-function nil | 643 | (defcustom reftex-translate-to-ascii-function 'reftex-latin1-to-ascii |
| 632 | "Filter function which will process a context string before it is used | 644 | "Filter function which will process a context string before it is used |
| 633 | to derive a label from it. A useful application would be to convert ISO or | 645 | to derive a label from it. The intended application is to convert ISO or |
| 634 | Mule characters into something legal in labels. By default, RefTeX just | 646 | Mule characters into something legal in labels. The default function |
| 635 | removes these characters. X-Symbol (>=2.6) sets this variable to | 647 | removes the accents from Latin-1 characters. X-Symbol (>=2.6) sets this |
| 636 | `x-symbol-translate-to-ascii'." | 648 | variable to the much more general `x-symbol-translate-to-ascii'." |
| 637 | :group 'reftex-making-and-inserting-labels | 649 | :group 'reftex-making-and-inserting-labels |
| 638 | :type 'symbol) | 650 | :type 'symbol) |
| 639 | 651 | ||
| @@ -667,16 +679,10 @@ DOWNCASE t: Downcase words before using them." | |||
| 667 | (string :tag "")) | 679 | (string :tag "")) |
| 668 | (option (boolean :tag "Downcase words ")))) | 680 | (option (boolean :tag "Downcase words ")))) |
| 669 | 681 | ||
| 670 | ;; The following rexexp is defined negative and excludes all Mule characters. | 682 | (defcustom reftex-label-illegal-re "[^-a-zA-Z0-9_+=:;,.]" |
| 671 | ;; A positive way to do it and to allow Mule characters at the same time | 683 | "Regexp matching characters not legal in labels." |
| 672 | ;; vwould be this: "[][\000-\037 !\"#$%&'()*,/<=>?@\\^`{|}~\177]" | ||
| 673 | (defcustom reftex-label-illegal-re "[^-a-zA-Z0-9_+=:;,.\300-\377]" | ||
| 674 | "Regexp matching characters not legal in labels. | ||
| 675 | For historic reasons, this character class comes *with* the [] brackets. | ||
| 676 | The default value allows the characters \300-\377 because these are the | ||
| 677 | european letters in ISO 8859-1." | ||
| 678 | :group 'reftex-making-and-inserting-labels | 684 | :group 'reftex-making-and-inserting-labels |
| 679 | :type '(regexp :tag "Character class")) | 685 | :type '(regexp :tag "Regular Expression")) |
| 680 | 686 | ||
| 681 | (defcustom reftex-abbrev-parameters '(4 2 "^aeiou" "aeiou") | 687 | (defcustom reftex-abbrev-parameters '(4 2 "^aeiou" "aeiou") |
| 682 | "Parameters for abbreviation of words. | 688 | "Parameters for abbreviation of words. |
| @@ -812,7 +818,7 @@ like, which are ignored by RefTeX anyway." | |||
| 812 | :type '(repeat (regexp))) | 818 | :type '(repeat (regexp))) |
| 813 | 819 | ||
| 814 | (defcustom reftex-default-bibliography nil | 820 | (defcustom reftex-default-bibliography nil |
| 815 | "*List of BibTeX database file which should be used if none are specified. | 821 | "*List of BibTeX database files which should be used if none are specified. |
| 816 | When `reftex-citation' is called from a document which has neither a | 822 | When `reftex-citation' is called from a document which has neither a |
| 817 | `\bibliography{..}' statement nor a `thebibliography' environment, | 823 | `\bibliography{..}' statement nor a `thebibliography' environment, |
| 818 | RefTeX will scan these files instead. Intended for using | 824 | RefTeX will scan these files instead. Intended for using |
| @@ -975,13 +981,18 @@ When nil, follow-mode will be suspended for stuff in unvisited files." | |||
| 975 | 981 | ||
| 976 | (defcustom reftex-auto-view-crossref t | 982 | (defcustom reftex-auto-view-crossref t |
| 977 | "*Non-nil means, initially turn automatic viewing of crossref info on. | 983 | "*Non-nil means, initially turn automatic viewing of crossref info on. |
| 978 | Automatic viewing of crossref info uses the echo area. Whenever point is in | 984 | Automatic viewing of crossref info normally uses the echo area. |
| 979 | the argument of a \\ref or \\cite macro, and no other message is being | 985 | Whenever point is on the argument of a \\ref or \\cite macro, and no |
| 980 | displayed, the echo area will display information about that cross reference. | 986 | other message is being displayed, the echo area will display |
| 987 | information about that cross reference. You can also set the variable | ||
| 988 | to the symbol `window'. In this case a small temporary window is | ||
| 989 | used for the display. | ||
| 981 | This feature can be turned on and of from the menu | 990 | This feature can be turned on and of from the menu |
| 982 | (Ref->Options->Crossref Viewing)." | 991 | (Ref->Options->Crossref Viewing)." |
| 983 | :group 'reftex-viewing-cross-references-and-citations | 992 | :group 'reftex-viewing-cross-references-and-citations |
| 984 | :type 'boolean) | 993 | :type '(choice (const :tag "off" nil) |
| 994 | (const :tag "in Echo Area" t) | ||
| 995 | (const :tag "in Other Window" window))) | ||
| 985 | 996 | ||
| 986 | (defcustom reftex-idle-time 1.2 | 997 | (defcustom reftex-idle-time 1.2 |
| 987 | "*Time (secs) Emacs has to be idle before automatic crossref display is done." | 998 | "*Time (secs) Emacs has to be idle before automatic crossref display is done." |
| @@ -1284,7 +1295,8 @@ construct: \\bbb [xxx] {aaa}." | |||
| 1284 | ;;; Define the formal stuff for a minor mode named RefTeX. | 1295 | ;;; Define the formal stuff for a minor mode named RefTeX. |
| 1285 | ;;; | 1296 | ;;; |
| 1286 | 1297 | ||
| 1287 | ;; This file corresponds to RefTeX version 3.34 | 1298 | (defconst reftex-version "RefTeX version 3.38" |
| 1299 | "Version string for RefTeX.") | ||
| 1288 | 1300 | ||
| 1289 | (defvar reftex-mode nil | 1301 | (defvar reftex-mode nil |
| 1290 | "Determines if RefTeX mode is active.") | 1302 | "Determines if RefTeX mode is active.") |
| @@ -1361,6 +1373,7 @@ on the menu bar. | |||
| 1361 | (defvar LaTeX-label-function) | 1373 | (defvar LaTeX-label-function) |
| 1362 | (defvar tex-main-file) | 1374 | (defvar tex-main-file) |
| 1363 | (defvar outline-minor-mode) | 1375 | (defvar outline-minor-mode) |
| 1376 | (defvar font-lock-mode) | ||
| 1364 | (defvar font-lock-fontify-region-function) | 1377 | (defvar font-lock-fontify-region-function) |
| 1365 | (defvar font-lock-syntactic-keywords) | 1378 | (defvar font-lock-syntactic-keywords) |
| 1366 | 1379 | ||
| @@ -1467,15 +1480,15 @@ on the menu bar. | |||
| 1467 | (buffer-file-name))))) | 1480 | (buffer-file-name))))) |
| 1468 | (cond | 1481 | (cond |
| 1469 | ((null master) | 1482 | ((null master) |
| 1470 | (error "Need a filename for this buffer. Please save it first.")) | 1483 | (error "Need a filename for this buffer, please save it first")) |
| 1471 | ((or (file-exists-p master) | ||
| 1472 | (reftex-get-buffer-visiting master)) | ||
| 1473 | ;; We either see the file, or have a buffer on it. OK. | ||
| 1474 | ) | ||
| 1475 | ((or (file-exists-p (concat master ".tex")) | 1484 | ((or (file-exists-p (concat master ".tex")) |
| 1476 | (reftex-get-buffer-visiting (concat master ".tex"))) | 1485 | (reftex-get-buffer-visiting (concat master ".tex"))) |
| 1477 | ;; Ahh, an extra .tex was missing... | 1486 | ;; Ahh, an extra .tex was missing... |
| 1478 | (setq master (concat master ".tex"))) | 1487 | (setq master (concat master ".tex"))) |
| 1488 | ((or (file-exists-p master) | ||
| 1489 | (reftex-get-buffer-visiting master)) | ||
| 1490 | ;; We either see the file, or have a buffer on it. OK. | ||
| 1491 | ) | ||
| 1479 | (t | 1492 | (t |
| 1480 | ;; Use buffer file name. | 1493 | ;; Use buffer file name. |
| 1481 | (buffer-file-name))) | 1494 | (buffer-file-name))) |
| @@ -2643,6 +2656,7 @@ SEP String separating different words in the output string. | |||
| 2643 | IGNORE-WORDS List of words which should be removed from the string." | 2656 | IGNORE-WORDS List of words which should be removed from the string." |
| 2644 | 2657 | ||
| 2645 | (let* ((words0 (split-string string (or split-re "[ \t\n\r]"))) | 2658 | (let* ((words0 (split-string string (or split-re "[ \t\n\r]"))) |
| 2659 | (reftex-label-illegal-re (or illegal-re "\000")) | ||
| 2646 | words word) | 2660 | words word) |
| 2647 | 2661 | ||
| 2648 | ;; Remove words from the ignore list or with funny characters | 2662 | ;; Remove words from the ignore list or with funny characters |
| @@ -2650,9 +2664,9 @@ IGNORE-WORDS List of words which should be removed from the string." | |||
| 2650 | (if downcase (setq word (downcase word))) | 2664 | (if downcase (setq word (downcase word))) |
| 2651 | (cond | 2665 | (cond |
| 2652 | ((member (downcase word) ignore-words)) | 2666 | ((member (downcase word) ignore-words)) |
| 2653 | ((string-match (or illegal-re "\000") word) | 2667 | ((string-match reftex-label-illegal-re word) |
| 2654 | (when illegal | 2668 | (when illegal |
| 2655 | (while (string-match illegal-re word) | 2669 | (while (string-match reftex-label-illegal-re word) |
| 2656 | (setq word (replace-match "" nil nil word))) | 2670 | (setq word (replace-match "" nil nil word))) |
| 2657 | (push word words))) | 2671 | (push word words))) |
| 2658 | (t | 2672 | (t |
| @@ -2692,6 +2706,17 @@ IGNORE-WORDS List of words which should be removed from the string." | |||
| 2692 | (setq string (replace-match "" nil nil string))) | 2706 | (setq string (replace-match "" nil nil string))) |
| 2693 | string)) | 2707 | string)) |
| 2694 | 2708 | ||
| 2709 | (defun reftex-latin1-to-ascii (string) | ||
| 2710 | ;; Translate the upper 127 chars in the ISO1 charset to ASCII equivalents | ||
| 2711 | (let ((tab "@@@@@@@@@@@@@@@@@@'@@@@@@@@@@@@@ icLxY|S\"ca<--R-o|23'uq..1o>423?AAAAAAACEEEEIIIIDNOOOOOXOUUUUYP3aaaaaaaceeeeiiiidnooooo:ouuuuypy") c) | ||
| 2712 | (loop for i from 0 to (1- (length string)) do | ||
| 2713 | (setq c (aref string i)) | ||
| 2714 | (cond ((and (> c 127) (< c 256)) ; 8 bit Latin-1 | ||
| 2715 | (aset string i (aref tab (- c 128)))) | ||
| 2716 | ((and (> c 2175) (< c 2304)) ; Mule Latin-1, | ||
| 2717 | (aset string i (aref tab (- c 2176)))))) ; Std. Emacs only | ||
| 2718 | string)) | ||
| 2719 | |||
| 2695 | (defun reftex-replace-prefix-escapes (prefix) | 2720 | (defun reftex-replace-prefix-escapes (prefix) |
| 2696 | ;; Replace %escapes in a label prefix | 2721 | ;; Replace %escapes in a label prefix |
| 2697 | (save-match-data | 2722 | (save-match-data |
| @@ -2844,7 +2869,7 @@ When called with 2 C-u prefix args, disable magic word recognition." | |||
| 2844 | 2869 | ||
| 2845 | ;; remove ~ if we do already have a space | 2870 | ;; remove ~ if we do already have a space |
| 2846 | (when (and (= ?~ (string-to-char form)) | 2871 | (when (and (= ?~ (string-to-char form)) |
| 2847 | (= ?\ (preceding-char))) | 2872 | (member (preceding-char) '(?\ ?\t ?\n))) |
| 2848 | (setq form (substring form 1))) | 2873 | (setq form (substring form 1))) |
| 2849 | ;; do we need to switch from \ref to \vref? | 2874 | ;; do we need to switch from \ref to \vref? |
| 2850 | (when (string= varioref "\\vref") | 2875 | (when (string= varioref "\\vref") |
| @@ -3271,7 +3296,7 @@ When called with 2 C-u prefix args, disable magic word recognition." | |||
| 3271 | (setq reftex-latex-syntax-table (syntax-table)) | 3296 | (setq reftex-latex-syntax-table (syntax-table)) |
| 3272 | (reftex-highlight 0 (match-beginning 3) (match-end 3)) | 3297 | (reftex-highlight 0 (match-beginning 3) (match-end 3)) |
| 3273 | (reftex-show-entry (match-beginning 3) (match-end 3)) | 3298 | (reftex-show-entry (match-beginning 3) (match-end 3)) |
| 3274 | (recenter (/ (window-height) 2))) | 3299 | (recenter '(4))) |
| 3275 | (select-window this-window)))) | 3300 | (select-window this-window)))) |
| 3276 | 3301 | ||
| 3277 | (defun reftex-pop-to-label (label file-list &optional mark-to-kill highlight) | 3302 | (defun reftex-pop-to-label (label file-list &optional mark-to-kill highlight) |
| @@ -3295,13 +3320,12 @@ When called with 2 C-u prefix args, disable magic word recognition." | |||
| 3295 | (when (re-search-forward re nil t) | 3320 | (when (re-search-forward re nil t) |
| 3296 | (switch-to-buffer-other-window buf) | 3321 | (switch-to-buffer-other-window buf) |
| 3297 | (goto-char (match-beginning 0)) | 3322 | (goto-char (match-beginning 0)) |
| 3298 | (recenter (/ (window-height) 2)) | 3323 | (recenter '(4)) |
| 3299 | (if highlight | 3324 | (if highlight |
| 3300 | (reftex-highlight 0 (match-beginning 3) (match-end 3))) | 3325 | (reftex-highlight 0 (match-beginning 3) (match-end 3))) |
| 3301 | (throw 'exit (selected-window))))) | 3326 | (throw 'exit (selected-window))))) |
| 3302 | (error "Label %s not found" label)))) | 3327 | (error "Label %s not found" label)))) |
| 3303 | 3328 | ||
| 3304 | (defvar font-lock-mode) | ||
| 3305 | (defun reftex-show-entry (beg-hlt end-hlt) | 3329 | (defun reftex-show-entry (beg-hlt end-hlt) |
| 3306 | ;; Show entry if point is hidden | 3330 | ;; Show entry if point is hidden |
| 3307 | (let* ((n (/ (window-height) 2)) | 3331 | (let* ((n (/ (window-height) 2)) |
| @@ -3570,7 +3594,7 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [f]ollow-mode e[x]tern [?]Help | |||
| 3570 | (switch-to-buffer-other-window | 3594 | (switch-to-buffer-other-window |
| 3571 | (marker-buffer reftex-toc-return-marker)) | 3595 | (marker-buffer reftex-toc-return-marker)) |
| 3572 | (goto-char (marker-position reftex-toc-return-marker)) | 3596 | (goto-char (marker-position reftex-toc-return-marker)) |
| 3573 | (recenter (/ (window-height) 2))) | 3597 | (recenter '(4))) |
| 3574 | (select-window this-window)))) | 3598 | (select-window this-window)))) |
| 3575 | (defun reftex-toc-quit () | 3599 | (defun reftex-toc-quit () |
| 3576 | "Hide the *toc* window and do not move point." | 3600 | "Hide the *toc* window and do not move point." |
| @@ -3593,7 +3617,7 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [f]ollow-mode e[x]tern [?]Help | |||
| 3593 | (if reftex-enable-partial-scans | 3617 | (if reftex-enable-partial-scans |
| 3594 | (let ((file (nth 3 (get-text-property (point) 'toc)))) | 3618 | (let ((file (nth 3 (get-text-property (point) 'toc)))) |
| 3595 | (if (not file) | 3619 | (if (not file) |
| 3596 | (error "Don't know which file to rescan. Try `R'.") | 3620 | (error "Don't know which file to rescan. Try `R'") |
| 3597 | (switch-to-buffer-other-window | 3621 | (switch-to-buffer-other-window |
| 3598 | (reftex-get-file-buffer-force file)) | 3622 | (reftex-get-file-buffer-force file)) |
| 3599 | (setq current-prefix-arg '(4)) | 3623 | (setq current-prefix-arg '(4)) |
| @@ -3803,7 +3827,7 @@ During a selection process, these are the local bindings. | |||
| 3803 | ;; If MARK-TO-KILL is non-nil, mark new buffer to kill. | 3827 | ;; If MARK-TO-KILL is non-nil, mark new buffer to kill. |
| 3804 | ;; If HIGHLIGHT is non-nil, highlight the match. | 3828 | ;; If HIGHLIGHT is non-nil, highlight the match. |
| 3805 | ;; If ITEM in non-nil, search for bibitem instead of database entry. | 3829 | ;; If ITEM in non-nil, search for bibitem instead of database entry. |
| 3806 | ;; If ECHO is non-nil, just display short info in echo area. | 3830 | ;; If RETURN is non-nil, just return the entry. |
| 3807 | 3831 | ||
| 3808 | (let* ((re | 3832 | (let* ((re |
| 3809 | (if item | 3833 | (if item |
| @@ -3827,18 +3851,9 @@ During a selection process, these are the local bindings. | |||
| 3827 | (goto-char (match-beginning 0)) | 3851 | (goto-char (match-beginning 0)) |
| 3828 | (when return | 3852 | (when return |
| 3829 | ;; Just return the relevant entry | 3853 | ;; Just return the relevant entry |
| 3830 | (setq return | 3854 | (if item (goto-char (match-end 0))) |
| 3831 | (if item | 3855 | (setq return (buffer-substring |
| 3832 | (buffer-substring | 3856 | (point) (reftex-end-of-bib-entry item))) |
| 3833 | (goto-char (match-end 0)) | ||
| 3834 | (if (re-search-forward | ||
| 3835 | "\\\\bibitem\\|\\\\end{thebibliography}" nil t) | ||
| 3836 | (match-beginning 0) | ||
| 3837 | (point))) | ||
| 3838 | (buffer-substring (point) | ||
| 3839 | (condition-case nil | ||
| 3840 | (progn (forward-list 1) (point)) | ||
| 3841 | (error (point)))))) | ||
| 3842 | (set-window-configuration window-conf) | 3857 | (set-window-configuration window-conf) |
| 3843 | (throw 'exit return)) | 3858 | (throw 'exit return)) |
| 3844 | (recenter 0) | 3859 | (recenter 0) |
| @@ -3850,6 +3865,17 @@ During a selection process, these are the local bindings. | |||
| 3850 | (error "No \\bibitem with citation key %s" key) | 3865 | (error "No \\bibitem with citation key %s" key) |
| 3851 | (error "No BibTeX entry with citation key %s" key))))) | 3866 | (error "No BibTeX entry with citation key %s" key))))) |
| 3852 | 3867 | ||
| 3868 | (defun reftex-end-of-bib-entry (item) | ||
| 3869 | (save-excursion | ||
| 3870 | (condition-case nil | ||
| 3871 | (if item | ||
| 3872 | (progn (end-of-line) | ||
| 3873 | (re-search-forward | ||
| 3874 | "\\\\bibitem\\|\\end{thebibliography}") | ||
| 3875 | (1- (match-beginning 0))) | ||
| 3876 | (progn (forward-list 1) (point))) | ||
| 3877 | (error (min (point-max) (+ 300 (point))))))) | ||
| 3878 | |||
| 3853 | ;; Parse bibtex buffers | 3879 | ;; Parse bibtex buffers |
| 3854 | 3880 | ||
| 3855 | (defun reftex-extract-bib-entries (buffers) | 3881 | (defun reftex-extract-bib-entries (buffers) |
| @@ -4304,11 +4330,13 @@ bibliography statement (e.g. if it was changed)." | |||
| 4304 | (delete-char 1)) | 4330 | (delete-char 1)) |
| 4305 | 4331 | ||
| 4306 | ;; Tell AUCTeX | 4332 | ;; Tell AUCTeX |
| 4307 | (when (and (fboundp 'LaTeX-add-bibitems) reftex-plug-into-AUCTeX) | 4333 | (when (and reftex-mode |
| 4334 | (fboundp 'LaTeX-add-bibitems) | ||
| 4335 | reftex-plug-into-AUCTeX) | ||
| 4308 | (apply 'LaTeX-add-bibitems (mapcar 'car selected-entries))) | 4336 | (apply 'LaTeX-add-bibitems (mapcar 'car selected-entries))) |
| 4309 | 4337 | ||
| 4310 | ;; Produce the cite-view strings | 4338 | ;; Produce the cite-view strings |
| 4311 | (when (and reftex-cache-cite-echo cite-view) | 4339 | (when (and reftex-mode reftex-cache-cite-echo cite-view) |
| 4312 | (mapcar (lambda (entry) | 4340 | (mapcar (lambda (entry) |
| 4313 | (reftex-make-cite-echo-string entry docstruct-symbol)) | 4341 | (reftex-make-cite-echo-string entry docstruct-symbol)) |
| 4314 | selected-entries)) | 4342 | selected-entries)) |
| @@ -4693,7 +4721,7 @@ bibliography statement (e.g. if it was changed)." | |||
| 4693 | (princ prompt) | 4721 | (princ prompt) |
| 4694 | (set-marker reftex-recursive-edit-marker (point)) | 4722 | (set-marker reftex-recursive-edit-marker (point)) |
| 4695 | ;; XEmacs does not run post-command-hook here | 4723 | ;; XEmacs does not run post-command-hook here |
| 4696 | (and (featurep 'xemacsp) (run-hooks 'post-command-hook)) | 4724 | (and (featurep 'xemacs) (run-hooks 'post-command-hook)) |
| 4697 | (recursive-edit)) | 4725 | (recursive-edit)) |
| 4698 | 4726 | ||
| 4699 | (set-marker reftex-recursive-edit-marker nil) | 4727 | (set-marker reftex-recursive-edit-marker nil) |
| @@ -4753,7 +4781,7 @@ bibliography statement (e.g. if it was changed)." | |||
| 4753 | (reftex-highlight 1 b e)) | 4781 | (reftex-highlight 1 b e)) |
| 4754 | (if (or (not (pos-visible-in-window-p b)) | 4782 | (if (or (not (pos-visible-in-window-p b)) |
| 4755 | (not (pos-visible-in-window-p e))) | 4783 | (not (pos-visible-in-window-p e))) |
| 4756 | (recenter (/ (window-height) 2))) | 4784 | (recenter '(4))) |
| 4757 | (unless (current-message) | 4785 | (unless (current-message) |
| 4758 | (princ prompt)))) | 4786 | (princ prompt)))) |
| 4759 | 4787 | ||
| @@ -4822,7 +4850,7 @@ bibliography statement (e.g. if it was changed)." | |||
| 4822 | (switch-to-buffer-other-window | 4850 | (switch-to-buffer-other-window |
| 4823 | (marker-buffer reftex-select-return-marker)) | 4851 | (marker-buffer reftex-select-return-marker)) |
| 4824 | (goto-char (marker-position reftex-select-return-marker)) | 4852 | (goto-char (marker-position reftex-select-return-marker)) |
| 4825 | (recenter (/ (window-height) 2))) | 4853 | (recenter '(4))) |
| 4826 | (select-window this-window)))) | 4854 | (select-window this-window)))) |
| 4827 | (defun reftex-select-callback () | 4855 | (defun reftex-select-callback () |
| 4828 | "Show full context in another window." | 4856 | "Show full context in another window." |
| @@ -4870,145 +4898,154 @@ bibliography statement (e.g. if it was changed)." | |||
| 4870 | ;;; | 4898 | ;;; |
| 4871 | ;;; View cross references | 4899 | ;;; View cross references |
| 4872 | 4900 | ||
| 4873 | (defun reftex-view-crossref (&optional arg stay-put echo) | 4901 | (defun reftex-view-crossref (&optional arg how) |
| 4874 | "View cross reference of \\ref or \\cite macro at point. | 4902 | "View cross reference of \\ref or \\cite macro at point. |
| 4875 | If the macro at point is a \\ref, show the corresponding label definition. | 4903 | If the macro at point is a \\ref, show the corresponding label definition. |
| 4876 | If it is a \\cite, show the BibTeX database entry or the \\bibitem. | 4904 | If it is a \\cite, show the BibTeX database entry or the \\bibitem. |
| 4877 | If there is no such macro at point, search forward to find one. | 4905 | To cope with the plethora of variations in packages, this |
| 4878 | When you call this function several times in direct succession, point will | 4906 | function assumes any macro either starting with or ending in `ref' or |
| 4879 | move to view subsequent cross references further down in the buffer. | 4907 | `cite' to contain cross references. |
| 4880 | To cope with the plethora of variations in packages, this function | ||
| 4881 | assumes any macro either starting with or ending in `ref' or `cite' to | ||
| 4882 | contain cross references. | ||
| 4883 | When the LaTeX package `xr' is being used, this command will also view | 4908 | When the LaTeX package `xr' is being used, this command will also view |
| 4884 | crossreferences in external documents. However, this works correctly only | 4909 | crossreferences in external documents. However, this works correctly only |
| 4885 | when the \\externaldocument macros are used with the optional label prefix | 4910 | when the \\externaldocument macros are used with the optional label prefix |
| 4886 | argument. | 4911 | argument. |
| 4887 | With one or two C-u prefixes, enforce rescanning of the document. | 4912 | With one or two C-u prefixes, enforce rescanning of the document. |
| 4888 | With argument t or 1, select the window showing the cross reference. | 4913 | With argument 2, select the window showing the cross reference. |
| 4889 | When STAY-PUT is non-nil, do not move. | 4914 | When HOW is 'echo, call the corresponding echo function. |
| 4890 | When ECHO is non-nil, use the echo area to display the cross reference." | 4915 | When HOW is 'tmp-window, make the pop-up window as small as possible and |
| 4916 | arrange for its removal before the next command." | ||
| 4891 | 4917 | ||
| 4892 | (interactive "P") | 4918 | (interactive "P") |
| 4893 | 4919 | ||
| 4894 | ;; See where we are. | 4920 | ;; See where we are. |
| 4895 | (let* ((re "\\\\\\([a-z]*\\(cite\\|ref\\)\\|\\(cite\\|ref\\)[a-z]*\\)\\**\\(\\[[^{}]*\\]\\)?{") | 4921 | (let* ((macro (car (reftex-what-macro 1))) |
| 4896 | (macro (car (reftex-what-macro 1))) | 4922 | (key (reftex-this-word "^{}%\n\r,"))) |
| 4897 | (this-word (reftex-this-word "*a-zA-Z\\\\")) | ||
| 4898 | (my-window (selected-window)) | ||
| 4899 | pop-window cmd args point) | ||
| 4900 | 4923 | ||
| 4901 | (setq reftex-call-back-to-this-buffer (current-buffer)) | 4924 | (setq reftex-call-back-to-this-buffer (current-buffer)) |
| 4902 | 4925 | ||
| 4903 | (catch 'exit | 4926 | (if (and macro |
| 4904 | (if (and macro | 4927 | (string-match "\\`\\\\cite\\|\\`\\\\ref\\|cite\\'\\|ref\\'" |
| 4905 | (string-match "\\`\\\\cite\\|\\`\\\\ref\\|cite\\'\\|ref\\'" | 4928 | macro)) |
| 4906 | macro)) | 4929 | (and (setq macro (match-string 0 macro)) |
| 4907 | (and (setq macro (match-string 0 macro)) | 4930 | (string-match "\\`\\\\" macro) |
| 4908 | (string-match "\\`\\\\" macro) | 4931 | (setq macro (substring macro 1))) |
| 4909 | (setq macro (substring macro 1))) | 4932 | (setq macro nil)) |
| 4910 | (setq macro nil)) | 4933 | |
| 4911 | 4934 | (if (or (null macro) (reftex-in-comment)) | |
| 4912 | ;; Exit here if we have no macro and are not allowed to move. | ||
| 4913 | (if (and stay-put (not macro)) (throw 'exit nil)) | ||
| 4914 | |||
| 4915 | (if (and macro | ||
| 4916 | (eq last-command this-command) | ||
| 4917 | (eq last-command 'reftex-view-crossref)) | ||
| 4918 | (if (string= macro "cite") | ||
| 4919 | (progn | ||
| 4920 | (skip-chars-forward "^},%") | ||
| 4921 | (while (and (eq (following-char) ?%) | ||
| 4922 | (or (beginning-of-line 2) t) | ||
| 4923 | (skip-chars-forward " \t\n\r"))) | ||
| 4924 | (skip-chars-forward ",") | ||
| 4925 | (if (eq (following-char) ?}) | ||
| 4926 | (setq macro nil))) | ||
| 4927 | (setq macro nil))) | ||
| 4928 | |||
| 4929 | (if (and (not macro) | ||
| 4930 | (or (not (string-match "\\`\\\\" this-word)) | ||
| 4931 | (eq (following-char) ?\\) | ||
| 4932 | (search-backward "\\" nil t) | ||
| 4933 | t)) | ||
| 4934 | (if (interactive-p) | ||
| 4935 | ;; Only move far if this function was called directly | ||
| 4936 | (and (re-search-forward re nil t) | ||
| 4937 | (setq macro (or (match-string 2) (match-string 3)))) | ||
| 4938 | ;; The macro needs to be at point | ||
| 4939 | (and (looking-at re) | ||
| 4940 | (setq macro (or (match-string 2) (match-string 3))) | ||
| 4941 | (goto-char (match-end 0))))) | ||
| 4942 | |||
| 4943 | |||
| 4944 | (unless macro | ||
| 4945 | (error "No cross reference to display")) | 4935 | (error "No cross reference to display")) |
| 4946 | 4936 | ||
| 4947 | ;; Ensure access to scanning info | 4937 | (if (eq how 'tmp-window) |
| 4948 | (reftex-access-scan-info (or arg current-prefix-arg)) | 4938 | ;; Remember the window configuration |
| 4939 | (put 'reftex-auto-view-crossref 'last-window-conf | ||
| 4940 | (current-window-configuration))) | ||
| 4941 | (cond | ||
| 4942 | ((string= macro "cite") | ||
| 4943 | (reftex-view-cr-cite arg key how)) | ||
| 4944 | ((string= macro "ref") | ||
| 4945 | (reftex-view-cr-ref arg key how)) | ||
| 4946 | (t | ||
| 4947 | (error "Cannot display crossref\n"))))) | ||
| 4948 | |||
| 4949 | (defun reftex-view-cr-cite (arg key how) | ||
| 4950 | ;; View crossreference of a ref cite. HOW can have the values | ||
| 4951 | ;; nil: Show in another window. | ||
| 4952 | ;; echo: Show one-line info in echo area. | ||
| 4953 | ;; tmp-window: Show in small window and arrange for window to disappear. | ||
| 4949 | 4954 | ||
| 4950 | (cond | 4955 | ;; Ensure access to scanning info |
| 4951 | ((reftex-in-comment) | 4956 | (reftex-access-scan-info (or arg current-prefix-arg)) |
| 4952 | (throw 'exit nil)) | 4957 | |
| 4953 | ((string= macro "cite") | 4958 | (let (files size item (pos (point)) (win (selected-window)) pop-win) |
| 4954 | (cond | 4959 | ;; Find the citation mode and the file list |
| 4955 | ((assq 'bib (symbol-value reftex-docstruct-symbol)) | 4960 | (cond |
| 4956 | (setq cmd 'reftex-pop-to-bibtex-entry | 4961 | ((assq 'bib (symbol-value reftex-docstruct-symbol)) |
| 4957 | args (list | 4962 | (setq item nil |
| 4958 | (reftex-this-word "^{},%\n\r") | 4963 | files (reftex-get-bibfile-list))) |
| 4959 | (reftex-get-bibfile-list) nil t nil))) | 4964 | ((assq 'thebib (symbol-value reftex-docstruct-symbol)) |
| 4960 | ((assq 'thebib (symbol-value reftex-docstruct-symbol)) | 4965 | (setq item t |
| 4961 | (setq cmd 'reftex-pop-to-bibtex-entry | 4966 | files (list (cdr (assq 'thebib |
| 4962 | args (list | 4967 | (symbol-value reftex-docstruct-symbol)))))) |
| 4963 | (reftex-this-word "^{},%\n\r") | 4968 | (reftex-default-bibliography |
| 4964 | (list (cdr (assq 'thebib | 4969 | (setq item nil |
| 4965 | (symbol-value reftex-docstruct-symbol)))) | 4970 | files reftex-default-bibliography)) |
| 4966 | nil t t))) | 4971 | (how) ;; don't throw for special display |
| 4967 | (reftex-default-bibliography | 4972 | (t (error "Cannot display crossref"))) |
| 4968 | (setq cmd 'reftex-pop-to-bibtex-entry | 4973 | |
| 4969 | args (list | 4974 | (if (eq how 'echo) |
| 4970 | (reftex-this-word "^{},%\n\r") | 4975 | ;; Display in Echo area |
| 4971 | reftex-default-bibliography nil t nil))) | 4976 | (reftex-echo-cite key files item) |
| 4972 | (echo) | 4977 | ;; Display in a window |
| 4973 | (t (error "Cannot display crossref\n"))) | 4978 | (if (not (eq how 'tmp-window)) |
| 4974 | (when echo | 4979 | ;; Normal display |
| 4975 | (reftex-echo-cite args) | 4980 | (reftex-pop-to-bibtex-entry key files nil t item) |
| 4976 | (throw 'exit nil))) | 4981 | ;; A temporary window |
| 4977 | ((string= macro "ref") | 4982 | (condition-case nil |
| 4978 | (let* ((label (reftex-this-word "^{}%\n\r")) | 4983 | (reftex-pop-to-bibtex-entry key files nil t item) |
| 4979 | (xr-data (assoc 'xr (symbol-value reftex-docstruct-symbol))) | 4984 | (error (goto-char pos) |
| 4980 | (xr-re (nth 2 xr-data)) | 4985 | (message "cite: no such citation key %s" key) |
| 4981 | (entry (assoc label (symbol-value reftex-docstruct-symbol)))) | 4986 | (error ""))) |
| 4982 | 4987 | ;; Resize the window | |
| 4983 | (if (and (not entry) (stringp label) xr-re (string-match xr-re label)) | 4988 | (setq size (max 1 (count-lines (point) |
| 4984 | ;; Label is defined in external document | 4989 | (reftex-end-of-bib-entry item)))) |
| 4985 | (save-excursion | 4990 | (let ((window-min-height 2)) |
| 4986 | (save-match-data | 4991 | (shrink-window (1- (- (window-height) size))) |
| 4987 | (set-buffer | 4992 | (recenter 0)) |
| 4988 | (or (reftex-get-file-buffer-force | 4993 | ;; Arrange restoration |
| 4989 | (cdr (assoc (match-string 1 label) (nth 1 | 4994 | (add-hook 'pre-command-hook 'reftex-restore-window-conf)) |
| 4990 | xr-data)))) | 4995 | |
| 4991 | (error "Problem with external label %s" label)))) | 4996 | ;; Normal display in other window |
| 4992 | (setq label (substring label (match-end 1))) | ||
| 4993 | (reftex-access-scan-info) | ||
| 4994 | (setq entry | ||
| 4995 | (assoc label (symbol-value reftex-docstruct-symbol))))) | ||
| 4996 | (when echo | ||
| 4997 | (reftex-echo-ref label entry (symbol-value reftex-docstruct-symbol)) | ||
| 4998 | (throw 'exit t)) | ||
| 4999 | (if entry | ||
| 5000 | (setq cmd 'reftex-pop-to-label | ||
| 5001 | args (list label (list (nth 3 entry)) nil t)) | ||
| 5002 | (error "Label %s not known - reparse document might help" label)))) | ||
| 5003 | (t (error "This should not happen (reftex-view-crossref)"))) | ||
| 5004 | (setq point (point)) | ||
| 5005 | (apply cmd args) | ||
| 5006 | (setq pop-window (selected-window)) | ||
| 5007 | (add-hook 'pre-command-hook 'reftex-highlight-shall-die) | 4997 | (add-hook 'pre-command-hook 'reftex-highlight-shall-die) |
| 5008 | (select-window my-window) | 4998 | (setq pop-win (selected-window)) |
| 5009 | (goto-char point) | 4999 | (select-window win) |
| 5010 | (when (or (equal arg t) (equal arg 1)) | 5000 | (goto-char pos) |
| 5011 | (select-window pop-window))))) | 5001 | (when (equal arg 2) |
| 5002 | (select-window pop-win))))) | ||
| 5003 | |||
| 5004 | (defun reftex-view-cr-ref (arg label how) | ||
| 5005 | ;; View crossreference of a ref macro. HOW can have the values | ||
| 5006 | ;; nil: Show in another window. | ||
| 5007 | ;; echo: Show one-line info in echo area. | ||
| 5008 | ;; tmp-window: Show in small window and arrange for window to disappear. | ||
| 5009 | |||
| 5010 | ;; Ensure access to scanning info | ||
| 5011 | (reftex-access-scan-info (or arg current-prefix-arg)) | ||
| 5012 | |||
| 5013 | (let* ((xr-data (assoc 'xr (symbol-value reftex-docstruct-symbol))) | ||
| 5014 | (xr-re (nth 2 xr-data)) | ||
| 5015 | (entry (assoc label (symbol-value reftex-docstruct-symbol))) | ||
| 5016 | (win (selected-window)) pop-win (pos (point))) | ||
| 5017 | |||
| 5018 | (if (and (not entry) (stringp label) xr-re (string-match xr-re label)) | ||
| 5019 | ;; Label is defined in external document | ||
| 5020 | (save-excursion | ||
| 5021 | (save-match-data | ||
| 5022 | (set-buffer | ||
| 5023 | (or (reftex-get-file-buffer-force | ||
| 5024 | (cdr (assoc (match-string 1 label) (nth 1 | ||
| 5025 | xr-data)))) | ||
| 5026 | (error "Problem with external label %s" label)))) | ||
| 5027 | (setq label (substring label (match-end 1))) | ||
| 5028 | (reftex-access-scan-info) | ||
| 5029 | (setq entry | ||
| 5030 | (assoc label (symbol-value reftex-docstruct-symbol))))) | ||
| 5031 | (if (eq how 'echo) | ||
| 5032 | (reftex-echo-ref label entry (symbol-value reftex-docstruct-symbol)) | ||
| 5033 | (unless entry | ||
| 5034 | (message "Label %s not known - reparse document might help" label)) | ||
| 5035 | |||
| 5036 | (reftex-pop-to-label label (list (nth 3 entry)) nil t) | ||
| 5037 | (add-hook 'pre-command-hook 'reftex-highlight-shall-die) | ||
| 5038 | |||
| 5039 | (when (eq how 'tmp-window) | ||
| 5040 | ;; Resize window and arrange restauration | ||
| 5041 | (shrink-window (1- (- (window-height) 9))) | ||
| 5042 | (recenter '(4)) | ||
| 5043 | (add-hook 'pre-command-hook 'reftex-restore-window-conf)) | ||
| 5044 | (setq pop-win (selected-window)) | ||
| 5045 | (select-window win) | ||
| 5046 | (goto-char pos) | ||
| 5047 | (when (equal arg 2) | ||
| 5048 | (select-window pop-win))))) | ||
| 5012 | 5049 | ||
| 5013 | (defun reftex-mouse-view-crossref (ev) | 5050 | (defun reftex-mouse-view-crossref (ev) |
| 5014 | "View cross reference of \\ref or \\cite macro where you click. | 5051 | "View cross reference of \\ref or \\cite macro where you click. |
| @@ -5024,20 +5061,34 @@ With argument, actually select the window showing the cross reference." | |||
| 5024 | "The timer used for auto-view-crossref.") | 5061 | "The timer used for auto-view-crossref.") |
| 5025 | 5062 | ||
| 5026 | (defun reftex-view-crossref-when-idle () | 5063 | (defun reftex-view-crossref-when-idle () |
| 5027 | ;; Display info about crossref at point in echo area. | 5064 | ;; Display info about crossref at point in echo area or a window. |
| 5028 | ;; This function was desigend to work with an idle timer. | 5065 | ;; This function was desigend to work with an idle timer. |
| 5029 | ;; We try to get out of here as quickly as possible if the call is useless. | 5066 | ;; We try to get out of here as quickly as possible if the call is useless. |
| 5030 | (and reftex-mode | 5067 | (and reftex-mode |
| 5031 | ;; Quick precheck if this might be a relevant spot | 5068 | ;; Quick precheck if this might be a relevant spot |
| 5069 | ;; FIXME: failes with backslash in comment | ||
| 5032 | (save-excursion | 5070 | (save-excursion |
| 5033 | (search-backward "\\" nil t) | 5071 | (search-backward "\\" nil t) |
| 5034 | (looking-at "\\\\[a-zA-Z]*\\(cite\\|ref\\)")) | 5072 | (looking-at "\\\\[a-zA-Z]*\\(cite\\|ref\\)")) |
| 5035 | ;; Make sure message area is free | 5073 | ;; Make sure message area is free if we need it. |
| 5036 | (not (current-message)) | 5074 | (or (eq reftex-auto-view-crossref 'window) (not (current-message))) |
| 5075 | ;; Make sure we are not already displaying this one | ||
| 5076 | (not (memq last-command '(reftex-view-crossref | ||
| 5077 | reftex-mouse-view-crossref))) | ||
| 5037 | (condition-case nil | 5078 | (condition-case nil |
| 5038 | (let ((current-prefix-arg nil)) | 5079 | (let ((current-prefix-arg nil)) |
| 5039 | (reftex-view-crossref -1 t t)) | 5080 | (cond |
| 5040 | (error nil)))) | 5081 | ((eq reftex-auto-view-crossref t) |
| 5082 | (reftex-view-crossref -1 'echo)) | ||
| 5083 | ((eq reftex-auto-view-crossref 'window) | ||
| 5084 | (reftex-view-crossref -1 'tmp-window)) | ||
| 5085 | (t nil))) | ||
| 5086 | (error nil)))) | ||
| 5087 | |||
| 5088 | (defun reftex-restore-window-conf () | ||
| 5089 | (set-window-configuration (get 'reftex-auto-view-crossref 'last-window-conf)) | ||
| 5090 | (put 'reftex-auto-view-crossref 'last-window-conf nil) | ||
| 5091 | (remove-hook 'pre-command-hook 'reftex-restore-window-conf)) | ||
| 5041 | 5092 | ||
| 5042 | (defun reftex-echo-ref (label entry docstruct) | 5093 | (defun reftex-echo-ref (label entry docstruct) |
| 5043 | ;; Display crossref info in echo area. | 5094 | ;; Display crossref info in echo area. |
| @@ -5055,14 +5106,11 @@ With argument, actually select the window showing the cross reference." | |||
| 5055 | (set-buffer buf) | 5106 | (set-buffer buf) |
| 5056 | (run-hooks 'reftex-display-copied-context-hook))))))) | 5107 | (run-hooks 'reftex-display-copied-context-hook))))))) |
| 5057 | 5108 | ||
| 5058 | (defun reftex-echo-cite (args) | 5109 | (defun reftex-echo-cite (key files item) |
| 5059 | ;; Display citation info in echo area. | 5110 | ;; Display citation info in echo area. |
| 5060 | (let* ((key (car args)) | 5111 | (let* ((cache (assq 'bibview-cache (symbol-value reftex-docstruct-symbol))) |
| 5061 | (cache (assq 'bibview-cache (symbol-value reftex-docstruct-symbol))) | ||
| 5062 | (cache-entry (assoc key (cdr cache))) | 5112 | (cache-entry (assoc key (cdr cache))) |
| 5063 | (item (nth 4 args)) | 5113 | entry string buf (all-files files)) |
| 5064 | (files (nth 1 args)) | ||
| 5065 | entry string buf) | ||
| 5066 | 5114 | ||
| 5067 | (if (and reftex-cache-cite-echo cache-entry) | 5115 | (if (and reftex-cache-cite-echo cache-entry) |
| 5068 | ;; We can just use the cache | 5116 | ;; We can just use the cache |
| @@ -5070,23 +5118,24 @@ With argument, actually select the window showing the cross reference." | |||
| 5070 | 5118 | ||
| 5071 | ;; Need to look in the database | 5119 | ;; Need to look in the database |
| 5072 | (unless reftex-revisit-to-echo | 5120 | (unless reftex-revisit-to-echo |
| 5073 | (setq files (reftex-visited-files (nth 1 args)))) | 5121 | (setq files (reftex-visited-files files))) |
| 5074 | 5122 | ||
| 5075 | (setq entry | 5123 | (setq entry |
| 5076 | (condition-case nil | 5124 | (condition-case nil |
| 5077 | (save-excursion | 5125 | (save-excursion |
| 5078 | (reftex-pop-to-bibtex-entry key files nil nil item t)) | 5126 | (reftex-pop-to-bibtex-entry key files nil nil item t)) |
| 5079 | (error | 5127 | (error |
| 5080 | (if (and files (= (length (nth 1 args)) (length files))) | 5128 | (if (and files (= (length all-files) (length files))) |
| 5081 | (message "cite: no such database entry: %s" key) | 5129 | (message "cite: no such database entry: %s" key) |
| 5082 | (message (substitute-command-keys | 5130 | (message (substitute-command-keys |
| 5083 | (format reftex-no-info-message "cite")))) | 5131 | (format reftex-no-info-message "cite")))) |
| 5084 | nil))) | 5132 | nil))) |
| 5085 | (when entry | 5133 | (when entry |
| 5086 | (setq entry (if item (reftex-parse-bibitem entry) | 5134 | (if item |
| 5087 | (reftex-parse-bibtex-entry entry))) | 5135 | (setq string (reftex-nicify-text entry)) |
| 5088 | (setq string (reftex-make-cite-echo-string | 5136 | (setq string (reftex-make-cite-echo-string |
| 5089 | entry reftex-docstruct-symbol)))) | 5137 | (reftex-parse-bibtex-entry entry) |
| 5138 | reftex-docstruct-symbol))))) | ||
| 5090 | (unless (or (null string) (equal string "")) | 5139 | (unless (or (null string) (equal string "")) |
| 5091 | (message "cite: %s" string)) | 5140 | (message "cite: %s" string)) |
| 5092 | (when (setq buf (get-buffer " *Echo Area*")) | 5141 | (when (setq buf (get-buffer " *Echo Area*")) |
| @@ -5236,6 +5285,7 @@ will display info in the echo area." | |||
| 5236 | ;; If the optional BOUND is an integer, bound backwards directed searches to | 5285 | ;; If the optional BOUND is an integer, bound backwards directed searches to |
| 5237 | ;; this point. If it is nil, limit to nearest \section - like statement. | 5286 | ;; this point. If it is nil, limit to nearest \section - like statement. |
| 5238 | 5287 | ||
| 5288 | (unless reftex-section-regexp (reftex-compile-variables)) | ||
| 5239 | (catch 'exit | 5289 | (catch 'exit |
| 5240 | (save-excursion | 5290 | (save-excursion |
| 5241 | (if (null which) (throw 'exit nil)) | 5291 | (if (null which) (throw 'exit nil)) |
| @@ -5266,9 +5316,12 @@ will display info in the echo area." | |||
| 5266 | ;; Find FILE in MASTER-DIR or on reftex-tex-path. | 5316 | ;; Find FILE in MASTER-DIR or on reftex-tex-path. |
| 5267 | ;; FILE may be given with or without the .tex extension. | 5317 | ;; FILE may be given with or without the .tex extension. |
| 5268 | (let ((rec-values '(nil t)) path file1 old-path) | 5318 | (let ((rec-values '(nil t)) path file1 old-path) |
| 5269 | (unless (and (file-name-absolute-p file) (not (file-exists-p file))) | 5319 | (if (file-name-absolute-p file) |
| 5320 | (if (file-regular-p (concat file ".tex")) | ||
| 5321 | (setq file1 (concat file ".tex")) | ||
| 5322 | (if (file-regular-p file) (setq file1 file))) | ||
| 5270 | (while (and (null file1) rec-values) | 5323 | (while (and (null file1) rec-values) |
| 5271 | (setq path (reftex-access-search-path | 5324 | (setq path (reftex-access-search-path |
| 5272 | "tex" (pop rec-values) master-dir file)) | 5325 | "tex" (pop rec-values) master-dir file)) |
| 5273 | (if (or (null old-path) | 5326 | (if (or (null old-path) |
| 5274 | (not (eq old-path path))) | 5327 | (not (eq old-path path))) |
| @@ -5284,7 +5337,8 @@ will display info in the echo area." | |||
| 5284 | (defun reftex-find-bib-file (file master-dir &optional die) | 5337 | (defun reftex-find-bib-file (file master-dir &optional die) |
| 5285 | ;; Find FILE in MASTER-DIR or on reftex-bib-path | 5338 | ;; Find FILE in MASTER-DIR or on reftex-bib-path |
| 5286 | (let ((rec-values '(nil t)) path file1 old-path) | 5339 | (let ((rec-values '(nil t)) path file1 old-path) |
| 5287 | (unless (and (file-name-absolute-p file) (not (file-exists-p file))) | 5340 | (if (file-name-absolute-p file) |
| 5341 | (if (file-regular-p file) (setq file1 file)) | ||
| 5288 | (while (and (null file1) rec-values) | 5342 | (while (and (null file1) rec-values) |
| 5289 | (setq path (reftex-access-search-path | 5343 | (setq path (reftex-access-search-path |
| 5290 | "bib" (pop rec-values) master-dir file)) | 5344 | "bib" (pop rec-values) master-dir file)) |
| @@ -5351,7 +5405,7 @@ will display info in the echo area." | |||
| 5351 | ;; DEF-DIR is the default directory for expanding relative path elements. | 5405 | ;; DEF-DIR is the default directory for expanding relative path elements. |
| 5352 | (catch 'exit | 5406 | (catch 'exit |
| 5353 | (when (file-name-absolute-p file) | 5407 | (when (file-name-absolute-p file) |
| 5354 | (if (and (file-exists-p file) (not (file-directory-p file))) | 5408 | (if (file-regular-p file) |
| 5355 | (throw 'exit file) | 5409 | (throw 'exit file) |
| 5356 | (throw 'exit nil))) | 5410 | (throw 'exit nil))) |
| 5357 | (let* ((thepath path) file1 dir ) | 5411 | (let* ((thepath path) file1 dir ) |
| @@ -5359,7 +5413,7 @@ will display info in the echo area." | |||
| 5359 | (when (string= (substring dir -2) "//") | 5413 | (when (string= (substring dir -2) "//") |
| 5360 | (setq dir (substring dir 0 -1))) | 5414 | (setq dir (substring dir 0 -1))) |
| 5361 | (setq file1 (expand-file-name file (expand-file-name dir def-dir))) | 5415 | (setq file1 (expand-file-name file (expand-file-name dir def-dir))) |
| 5362 | (if (and (file-exists-p file1) (not (file-directory-p file1))) | 5416 | (if (file-regular-p file1) |
| 5363 | (throw 'exit file1))) | 5417 | (throw 'exit file1))) |
| 5364 | ;; No such file | 5418 | ;; No such file |
| 5365 | nil))) | 5419 | nil))) |
| @@ -5485,6 +5539,7 @@ will display info in the echo area." | |||
| 5485 | (cond | 5539 | (cond |
| 5486 | ((and (boundp 'enable-multibyte-characters) | 5540 | ((and (boundp 'enable-multibyte-characters) |
| 5487 | enable-multibyte-characters | 5541 | enable-multibyte-characters |
| 5542 | (fboundp 'string-width) | ||
| 5488 | (fboundp 'truncate-string-to-width)) | 5543 | (fboundp 'truncate-string-to-width)) |
| 5489 | (if (<= (string-width string) ncols) | 5544 | (if (<= (string-width string) ncols) |
| 5490 | string | 5545 | string |
| @@ -6150,7 +6205,7 @@ The TAGS file is also immediately visited with `visit-tags-table'." | |||
| 6150 | (defun reftex-grep-document (grep-cmd) | 6205 | (defun reftex-grep-document (grep-cmd) |
| 6151 | "Run grep query through all files related to this document. | 6206 | "Run grep query through all files related to this document. |
| 6152 | With prefix arg, force to rescan document. | 6207 | With prefix arg, force to rescan document. |
| 6153 | This works also without an active TAGS table." | 6208 | No active TAGS table is required." |
| 6154 | 6209 | ||
| 6155 | (interactive | 6210 | (interactive |
| 6156 | (list (read-from-minibuffer "Run grep on document (like this): " | 6211 | (list (read-from-minibuffer "Run grep on document (like this): " |
| @@ -6167,7 +6222,7 @@ This works also without an active TAGS table." | |||
| 6167 | "Regexp search through all files of the current TeX document. | 6222 | "Regexp search through all files of the current TeX document. |
| 6168 | Starts always in the master file. Stops when a match is found. | 6223 | Starts always in the master file. Stops when a match is found. |
| 6169 | To continue searching for next match, use command \\[tags-loop-continue]. | 6224 | To continue searching for next match, use command \\[tags-loop-continue]. |
| 6170 | This works also without an active TAGS table." | 6225 | No active TAGS table is required." |
| 6171 | (interactive) | 6226 | (interactive) |
| 6172 | (let ((default (reftex-this-word))) | 6227 | (let ((default (reftex-this-word))) |
| 6173 | (unless regexp | 6228 | (unless regexp |
| @@ -6183,7 +6238,7 @@ This works also without an active TAGS table." | |||
| 6183 | Third arg DELIMITED (prefix arg) means replace only word-delimited matches. | 6238 | Third arg DELIMITED (prefix arg) means replace only word-delimited matches. |
| 6184 | If you exit (\\[keyboard-quit] or ESC), you can resume the query replace | 6239 | If you exit (\\[keyboard-quit] or ESC), you can resume the query replace |
| 6185 | with the command \\[tags-loop-continue]. | 6240 | with the command \\[tags-loop-continue]. |
| 6186 | This works also without an active TAGS table." | 6241 | No active TAGS table is required." |
| 6187 | (interactive) | 6242 | (interactive) |
| 6188 | (let ((default (reftex-this-word))) | 6243 | (let ((default (reftex-this-word))) |
| 6189 | (unless from | 6244 | (unless from |
| @@ -6263,7 +6318,7 @@ This works also without an active TAGS table." | |||
| 6263 | Works on the entire multifile document. | 6318 | Works on the entire multifile document. |
| 6264 | If you exit (\\[keyboard-quit] or ESC), you can resume the query replace | 6319 | If you exit (\\[keyboard-quit] or ESC), you can resume the query replace |
| 6265 | with the command \\[tags-loop-continue]. | 6320 | with the command \\[tags-loop-continue]. |
| 6266 | This works also without an active TAGS table." | 6321 | No active TAGS table is required." |
| 6267 | (interactive) | 6322 | (interactive) |
| 6268 | (let ((default (reftex-this-word "-a-zA-Z0-9_*.:"))) | 6323 | (let ((default (reftex-this-word "-a-zA-Z0-9_*.:"))) |
| 6269 | (unless from | 6324 | (unless from |
| @@ -6836,8 +6891,13 @@ for possible values. This function should be used from AUCTeX style files." | |||
| 6836 | ["Not" (setq reftex-sort-bibtex-matches nil) | 6891 | ["Not" (setq reftex-sort-bibtex-matches nil) |
| 6837 | :style radio :selected (eq reftex-sort-bibtex-matches nil)]) | 6892 | :style radio :selected (eq reftex-sort-bibtex-matches nil)]) |
| 6838 | ("Crossref Viewing" | 6893 | ("Crossref Viewing" |
| 6839 | ["Automatic Info in Echo Area" reftex-toggle-auto-view-crossref | 6894 | ["Automatic Info" reftex-toggle-auto-view-crossref |
| 6840 | :style toggle :selected reftex-auto-view-crossref-timer] | 6895 | :style toggle :selected reftex-auto-view-crossref-timer] |
| 6896 | ["...in Echo Area" (setq reftex-auto-view-crossref t) | ||
| 6897 | :style radio :selected (eq reftex-auto-view-crossref t)] | ||
| 6898 | ["...in Other Window" (setq reftex-auto-view-crossref 'window) | ||
| 6899 | :style radio :selected (eq reftex-auto-view-crossref 'window)] | ||
| 6900 | "---" | ||
| 6841 | ["Crossref Echo may visit files" | 6901 | ["Crossref Echo may visit files" |
| 6842 | (setq reftex-revisit-to-echo (not reftex-revisit-to-echo)) | 6902 | (setq reftex-revisit-to-echo (not reftex-revisit-to-echo)) |
| 6843 | :style toggle :selected reftex-revisit-to-echo] | 6903 | :style toggle :selected reftex-revisit-to-echo] |