diff options
| author | Carsten Dominik | 1998-11-13 16:17:25 +0000 |
|---|---|---|
| committer | Carsten Dominik | 1998-11-13 16:17:25 +0000 |
| commit | f9ad2e24c7c7c07822d58adb0d9c0f0abb1d08fc (patch) | |
| tree | f18e6f29d150412d225ebc13d1df4717b8a8b6e0 | |
| parent | 8f3e53fc603fa2c570b39b030a58eb99fa59a61f (diff) | |
| download | emacs-f9ad2e24c7c7c07822d58adb0d9c0f0abb1d08fc.tar.gz emacs-f9ad2e24c7c7c07822d58adb0d9c0f0abb1d08fc.zip | |
(reftex-finding-files): Group documentation fixed.
(reftex-toc-toggle-file-boundary, reftex-toc-toggle-labels,
reftex-toc-toggle-context,reftex-find-start-point): New functions.
(reftex-toc-include-labels, reftex-toc-include-context,
reftex-toc-include-file-boundaries,
reftex-toc-keep-other-windows): New options.
(reftex-use-text-after-label-as-context): Option removed.
(reftex-extract-bib-entries): Protect use in non-latex buffers.
(reftex-toc-visit-location): Renamed from `reftex-toc-visit-line'.
(reftex-latin1-to-ascii): Works now with and without Mule.
(reftex-truncate): Removed special stuff for Emacs 20.2.
(reftex-get-offset): Made more general.
(reftex-show-label-location): Renamed from
`reftex-select-label-callback'.
(reftex-pop-to-label): Function removed (using
`reftex-show-label-location' instead.
(reftex-insert-docstruct): Renamed from
`reftex-make-and-insert-label-list'. Function args changed.
(reftex-toc): Now uses `reftex-insert-docstruct' and
`reftex-find-start-point'.
(reftex-select-item): Use `reftex-find-start-point'.
(reftex-toc-visit-line): Can display labels and file boundaries.
(reftex-TeX-master-file): `(TeX-master-file)' protected.
| -rw-r--r-- | lisp/textmodes/reftex.el | 1125 |
1 files changed, 621 insertions, 504 deletions
diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el index 47389c63e7d..664f7be6807 100644 --- a/lisp/textmodes/reftex.el +++ b/lisp/textmodes/reftex.el | |||
| @@ -25,29 +25,30 @@ | |||
| 25 | ;; | 25 | ;; |
| 26 | ;;; Commentary: | 26 | ;;; Commentary: |
| 27 | ;; | 27 | ;; |
| 28 | ;; RefTeX is a minor mode with distinct support for \ref, \label and | 28 | ;; RefTeX is a minor mode with distinct support for \ref, \label, and \cite |
| 29 | ;; \cite commands in (multi-file) LaTeX documents. | 29 | ;; commands in (multi-file) LaTeX documents. |
| 30 | ;; Labels are created semi-automatically. Definition context of labels is | 30 | ;; - A table of contents provides easy access to any part of a document. |
| 31 | ;; provided when creating a reference. Citations are simplified with | 31 | ;; - Labels are created semi-automatically. |
| 32 | ;; efficient database lookup. A table of contents buffer provides easy | 32 | ;; - Definition context of labels is provided when creating a reference. |
| 33 | ;; access to any part of a document. | 33 | ;; - Citations are simplified with efficient database lookup. |
| 34 | ;; | 34 | ;; |
| 35 | ;; | 35 | ;; |
| 36 | ;; INSTALLATION | 36 | ;; INSTALLATION |
| 37 | ;; ------------ | 37 | ;; ------------ |
| 38 | ;; | 38 | ;; |
| 39 | ;; If you got reftex.el with an Emacs distribution, it is already | 39 | ;; - If this file is part of an X/Emacs distribution, it is installed. |
| 40 | ;; installed. If not, follow the instructions in the INSTALL file of | 40 | ;; - For XEmacs 21.x, you need to install the RefTeX plug-in package |
| 41 | ;; the distribution. | 41 | ;; available from the XEmacs distribution sites. |
| 42 | ;; - If you have downloaded this file from the maintainers webpage, follow | ||
| 43 | ;; the instructions in the INSTALL file of the distrubution. | ||
| 42 | ;; | 44 | ;; |
| 43 | ;; To turn RefTeX Mode on and off in a particular buffer, use | 45 | ;; To turn RefTeX Mode on and off in a buffer, use `M-x reftex-mode'. |
| 44 | ;; `M-x reftex-mode'. | ||
| 45 | ;; | 46 | ;; |
| 46 | ;; To turn on RefTeX Mode for all LaTeX files, add one of the following | 47 | ;; To turn on RefTeX Mode for all LaTeX files, add the following lines |
| 47 | ;; lines to your .emacs file: | 48 | ;; to your .emacs file: |
| 48 | ;; | 49 | ;; |
| 49 | ;; (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode | 50 | ;; (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; AUCTeX LaTeX mode |
| 50 | ;; (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode | 51 | ;; (add-hook 'latex-mode-hook 'turn-on-reftex) ; Emacs latex mode |
| 51 | ;; | 52 | ;; |
| 52 | ;; | 53 | ;; |
| 53 | ;; DOCUMENTATION | 54 | ;; DOCUMENTATION |
| @@ -56,87 +57,81 @@ | |||
| 56 | ;; See below for a short summary of how to use RefTeX. | 57 | ;; See below for a short summary of how to use RefTeX. |
| 57 | ;; | 58 | ;; |
| 58 | ;; There is an extensive texinfo document describing RefTeX in detail. | 59 | ;; There is an extensive texinfo document describing RefTeX in detail. |
| 59 | ;; When you are getting reftex.el with the Emacs distribution, the | 60 | ;; One way to view this documentation is `M-x reftex-info RET'. |
| 60 | ;; info files should already be installed. To view this | ||
| 61 | ;; documentation, use `M-x reftex-info RET'. | ||
| 62 | ;; | 61 | ;; |
| 63 | ;; The documentation in various formats is also available at | 62 | ;; The documentation in various formats is also available at |
| 64 | ;; | 63 | ;; |
| 65 | ;; http://www.strw.leidenuniv.nl/~dominik/Tools/ | 64 | ;; http://www.strw.leidenuniv.nl/~dominik/Tools/ |
| 66 | ;; | 65 | ;; |
| 67 | ;;--------------------------------------------------------------------------- | 66 | ;;--------------------------------------------------------------------------- |
| 68 | ;; | 67 | ;; |
| 69 | ;; RefTeX in a Nutshell | 68 | ;; RefTeX in a Nutshell |
| 70 | ;; ==================== | 69 | ;; ==================== |
| 71 | ;; | ||
| 72 | ;; 1. Labels and References | ||
| 73 | ;; RefTeX distinguishes labels for different environments. It knows | ||
| 74 | ;; about all standard environments (and many others), and can be | ||
| 75 | ;; configured to recognize any additional labeled environments you | ||
| 76 | ;; have defined yourself (variable REFTEX-LABEL-ALIST). | ||
| 77 | ;; | 70 | ;; |
| 78 | ;; * Creating Labels | 71 | ;; 1. Table of Contents |
| 79 | ;; Type `C-c (' (`reftex-label') to insert a label at point. | 72 | ;; Typing `C-c =' (`reftex-toc') will show a table of contents of the |
| 80 | ;; RefTeX will either | 73 | ;; document. From that buffer, you can jump quickly to every part of |
| 81 | ;; - derive a label from context (default for section labels) | 74 | ;; your document. Press `?' to get help. |
| 82 | ;; - prompt for a label string (default for figures and | 75 | ;; |
| 83 | ;; tables) or | 76 | ;; 2. Labels and References |
| 84 | ;; - insert a simple label made of a prefix and a number (all | 77 | ;; RefTeX distinguishes labels for different environments. It knows |
| 85 | ;; other environments). | 78 | ;; about all standard environments (and many others), and can be |
| 86 | ;; Which labels are created how is configurable (variable | 79 | ;; configured to recognize any additional labeled environments you |
| 87 | ;; REFTEX-INSERT-LABEL-FLAGS). | 80 | ;; have defined yourself (variable REFTEX-LABEL-ALIST). |
| 88 | ;; | 81 | ;; |
| 89 | ;; * Referencing Labels | 82 | ;; * Creating Labels |
| 90 | ;; In order to make a reference, type `C-c )' | 83 | ;; Type `C-c (' (`reftex-label') to insert a label at point. RefTeX |
| 91 | ;; (`reftex-reference'). This shows an outline of the document | 84 | ;; will either |
| 92 | ;; with all labels of a certain type (figure, equation,...) and | 85 | ;; - derive a label from context (default for section labels) |
| 93 | ;; context of the label definition. Selecting a label inserts a | 86 | ;; - prompt for a label string (default for figures and tables) or |
| 94 | ;; `\ref{LABEL}' macro into the original buffer. | 87 | ;; - insert a simple label made of a prefix and a number (all other |
| 88 | ;; environments) | ||
| 95 | ;; | 89 | ;; |
| 96 | ;; 2. Citations | 90 | ;; Which labels are created how is configurable with the variable |
| 97 | ;; After typing `C-c [' (`reftex-citation'), RefTeX will let you | 91 | ;; REFTEX-INSERT-LABEL-FLAGS. |
| 98 | ;; specify a regular expression to search in current BibTeX database | ||
| 99 | ;; files (as specified in the `\bibliography' command) and pull out a | ||
| 100 | ;; list of matches for you to choose from. The list is *formatted* | ||
| 101 | ;; and sorted. The selected article is referenced as `\cite{KEY}' | ||
| 102 | ;; (customizable with variable REFTEX-CITE-FORMAT). | ||
| 103 | ;; | 92 | ;; |
| 104 | ;; 3. Viewing Cross References | 93 | ;; * Referencing Labels |
| 105 | ;; When no other message occupies the echo area and point is idle on | 94 | ;; To make a reference, type `C-c )' (`reftex-reference'). This |
| 106 | ;; the argument of a `\ref' or `\cite' macro, the echo area will | 95 | ;; shows an outline of the document with all labels of a certain type |
| 107 | ;; display information about the citation/cross reference. | 96 | ;; (figure, equation,...) and some label context. Selecting a label |
| 108 | ;; With point on the argument of such a macro, press `C-c &' | 97 | ;; inserts a `\ref{LABEL}' macro into the original buffer. |
| 109 | ;; (`reftex-view-crossref'), or click with `S-mouse-2' on the macro | ||
| 110 | ;; argument. This will display the corresponding label definition or | ||
| 111 | ;; BibTeX database entry in another window. | ||
| 112 | ;; | 98 | ;; |
| 113 | ;; 4. Table of Contents | 99 | ;; 3. Citations |
| 114 | ;; Typing `C-c =' (`reftex-toc') will show a table of contents of the | 100 | ;; Typing `C-c [' (`reftex-citation') will let you specify a regular |
| 115 | ;; document. From that buffer, you can jump quickly to every part of | 101 | ;; expression to search in current BibTeX database files (as |
| 116 | ;; your document. | 102 | ;; specified in the `\bibliography' command) and pull out a list of |
| 103 | ;; matches for you to choose from. The list is *formatted* and | ||
| 104 | ;; sorted. The selected article is referenced as `\cite{KEY}' (see | ||
| 105 | ;; also the variable REFTEX-CITE-FORMAT). | ||
| 117 | ;; | 106 | ;; |
| 118 | ;; 5. Multifile Documents | 107 | ;; 4. Viewing Cross References |
| 119 | ;; Multifile Documents are fully supported. RefTeX will provide cross | 108 | ;; When point is idle on the argument of a `\ref' or `\cite' macro, |
| 120 | ;; referencing information from all files which are part of the | 109 | ;; the echo area will (if it is empty) display information about the |
| 121 | ;; document, and even across document borders (`xr.sty'). | 110 | ;; citation/cross reference. Press `C-c &' (`reftex-view-crossref'), |
| 111 | ;; or click with `S-mouse-2' on the macro argument to display the | ||
| 112 | ;; corresponding label definition or BibTeX database entry in another | ||
| 113 | ;; window. | ||
| 122 | ;; | 114 | ;; |
| 123 | ;; 6. Document Parsing | 115 | ;; 5. Multifile Documents |
| 124 | ;; RefTeX needs to parse the document in order to find labels and | 116 | ;; Multifile Documents are fully supported. RefTeX provides cross |
| 125 | ;; other information. It does it automatically once, when you start | 117 | ;; referencing information from all files which are part of the |
| 126 | ;; working with a document. RefTeX updates its lists internally when | 118 | ;; document, and across document borders (`xr.sty'). |
| 127 | ;; you make a new label with `reftex-label'. To enforce reparsing, | ||
| 128 | ;; call any of the commands described above with a raw `C-u' prefix, | ||
| 129 | ;; or press the `r' key in the label selection buffer or the table of | ||
| 130 | ;; contents buffer. | ||
| 131 | ;; | 119 | ;; |
| 132 | ;; 7. Useful Settings | 120 | ;; 6. Document Parsing |
| 133 | ;; To make RefTeX faster for large documents include, and to integrate | 121 | ;; RefTeX needs to parse the document in order to find labels and |
| 134 | ;; it with AUCTeX, try these: | 122 | ;; other information. It does it automatically once and updates its |
| 123 | ;; list internally when `reftex-label' is used. To enforce | ||
| 124 | ;; reparsing, call any of the commands described above with a raw | ||
| 125 | ;; `C-u' prefix, or press the `r' key in the label selection buffer | ||
| 126 | ;; or the table of contents buffer. | ||
| 135 | ;; | 127 | ;; |
| 136 | ;; (setq reftex-enable-partial-scans t) | 128 | ;; 7. Useful Settings |
| 137 | ;; (setq reftex-save-parse-info t) | 129 | ;; To make RefTeX faster for large documents, and to integrate with |
| 138 | ;; (setq reftex-use-multiple-selection-buffers t) | 130 | ;; AUCTeX, try these: |
| 139 | ;; (setq reftex-plug-into-AUCTeX t) | 131 | ;; (setq reftex-enable-partial-scans t) |
| 132 | ;; (setq reftex-save-parse-info t) | ||
| 133 | ;; (setq reftex-use-multiple-selection-buffers t) | ||
| 134 | ;; (setq reftex-plug-into-AUCTeX t) | ||
| 140 | ;; | 135 | ;; |
| 141 | ;;--------------------------------------------------------------------------- | 136 | ;;--------------------------------------------------------------------------- |
| 142 | ;; | 137 | ;; |
| @@ -147,28 +142,25 @@ | |||
| 147 | ;; | 142 | ;; |
| 148 | ;; with contributions from Stephen Eglen | 143 | ;; with contributions from Stephen Eglen |
| 149 | ;; | 144 | ;; |
| 150 | ;; The newest version of RefTeX can be found at | 145 | ;; RefTeX is bundled with Emacs and available as a plug-in package for |
| 146 | ;; XEmacs 21.x. If you need to install it yourself, you can find a | ||
| 147 | ;; distribution at | ||
| 151 | ;; | 148 | ;; |
| 152 | ;; http://www.strw.leidenuniv.nl/~dominik/Tools/ | 149 | ;; http://www.strw.leidenuniv.nl/~dominik/Tools/ |
| 153 | ;; ftp://ftp.strw.leidenuniv.nl/pub/dominik/ | ||
| 154 | ;; | ||
| 155 | ;; At that site you can also get version 3.22 of RefTeX which is still | ||
| 156 | ;; compatible with Emacs 19. The file you are reading now as well as the | ||
| 157 | ;; ones distributed with Emacs 20 are not. | ||
| 158 | ;; | 150 | ;; |
| 159 | ;; THANKS TO: | 151 | ;; THANKS TO: |
| 160 | ;; --------- | 152 | ;; --------- |
| 161 | ;; Thanks to the people on the Net who have used RefTeX and helped | 153 | ;; Thanks to the people on the Net who have used RefTeX and helped |
| 162 | ;; developing it with their reports. In particular thanks to | 154 | ;; developing it with their reports. In particular thanks to |
| 163 | ;; | 155 | ;; |
| 164 | ;; F. Burstall, Alastair Burt, Soren Dayton, Stephen Eglen, | 156 | ;; Fran Burstall, Alastair Burt, Soren Dayton, Stephen Eglen, |
| 165 | ;; Karl Eichwalder, Peter Galbraith, Dieter Kraft, Kai Grossjohann, | 157 | ;; Karl Eichwalder, Peter Galbraith, Dieter Kraft, Kai Grossjohann, |
| 166 | ;; Adrian Lanz, Rory Molinari, Laurent Mugnier, Sudeep Kumar Palat, | 158 | ;; Adrian Lanz, Rory Molinari, Laurent Mugnier, Sudeep Kumar Palat, |
| 167 | ;; Daniel Polani, Robin Socha, Richard Stanton, Allan Strand, | 159 | ;; Daniel Polani, Robin Socha, Richard Stanton, Allan Strand, |
| 168 | ;; Jan Vroonhof, Christoph Wedler, Alan Williams. | 160 | ;; Jan Vroonhof, Christoph Wedler, Alan Williams. |
| 169 | ;; | 161 | ;; |
| 170 | ;; Finally thanks to Uwe Bolick who first got me (some years ago) into | 162 | ;; Finally thanks to Uwe Bolick who first got me (some years ago) into |
| 171 | ;; supporting LaTeX labels and references with an Editor (which was | 163 | ;; supporting LaTeX labels and references with an editor (which was |
| 172 | ;; MicroEmacs at the time). | 164 | ;; MicroEmacs at the time). |
| 173 | ;; | 165 | ;; |
| 174 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 166 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| @@ -289,8 +281,7 @@ Lower-case symbols correspond to a style file of the same name in the LaTeX | |||
| 289 | distribution. Mixed-case symbols are convenience aliases.") | 281 | distribution. Mixed-case symbols are convenience aliases.") |
| 290 | 282 | ||
| 291 | (defconst reftex-cite-format-builtin | 283 | (defconst reftex-cite-format-builtin |
| 292 | '( | 284 | '((default "Default macro \\cite{%l}" |
| 293 | (default "Default macro \\cite{%l}" | ||
| 294 | "\\cite{%l}") | 285 | "\\cite{%l}") |
| 295 | (natbib "The Natbib package" | 286 | (natbib "The Natbib package" |
| 296 | ((?\C-m . "\\cite{%l}") | 287 | ((?\C-m . "\\cite{%l}") |
| @@ -347,9 +338,64 @@ The following conventions are valid for all alist entries: | |||
| 347 | :link '(url-link :tag "Home Page" | 338 | :link '(url-link :tag "Home Page" |
| 348 | "http://strw.leidenuniv.nl/~dominik/Tools/") | 339 | "http://strw.leidenuniv.nl/~dominik/Tools/") |
| 349 | :link '(emacs-commentary-link :tag "Commentary in reftex.el" "reftex.el") | 340 | :link '(emacs-commentary-link :tag "Commentary in reftex.el" "reftex.el") |
| 341 | :link '(custom-manual "(reftex)Top") | ||
| 350 | :prefix "reftex-" | 342 | :prefix "reftex-" |
| 351 | :group 'tex) | 343 | :group 'tex) |
| 352 | 344 | ||
| 345 | ;; Table of contents configuration -------------------------------------- | ||
| 346 | |||
| 347 | (defgroup reftex-table-of-contents-browser nil | ||
| 348 | "A multifile table of contents browser." | ||
| 349 | :group 'reftex) | ||
| 350 | |||
| 351 | (defcustom reftex-toc-keep-other-windows t | ||
| 352 | "*Non-nil means, split the selected window to display the *toc* buffer. | ||
| 353 | This helps to keep the window configuration, but makes the *toc* small. | ||
| 354 | When nil, all other windows except the selected one will be deleted, so | ||
| 355 | that the *toc* window fills half the frame." | ||
| 356 | :group 'reftex-table-of-contents-browser | ||
| 357 | :type 'boolean) | ||
| 358 | |||
| 359 | (defcustom reftex-toc-include-labels nil | ||
| 360 | "*Non-nil means, include labels in *toc* buffer. | ||
| 361 | This flag can be toggled from within the *toc* buffer with the `l' key." | ||
| 362 | :group 'reftex-table-of-contents-browser | ||
| 363 | :type 'boolean) | ||
| 364 | |||
| 365 | (defcustom reftex-toc-include-context nil | ||
| 366 | "*Non-nil means, include context with labels in the *toc* buffer. | ||
| 367 | Context will only be shown when labels are visible as well. | ||
| 368 | This flag can be toggled from within the *toc* buffer with the `c' key." | ||
| 369 | :group 'reftex-table-of-contents-browser | ||
| 370 | :type 'boolean) | ||
| 371 | |||
| 372 | (defcustom reftex-toc-include-file-boundaries nil | ||
| 373 | "*Non-nil means, include file boundaries in *toc* buffer. | ||
| 374 | This flag can be toggled from within the *toc* buffer with the `i' key." | ||
| 375 | :group 'reftex-table-of-contents-browser | ||
| 376 | :type 'boolean) | ||
| 377 | |||
| 378 | (defcustom reftex-toc-follow-mode nil | ||
| 379 | "*Non-nil means, point in *toc* buffer will cause other window to follow. | ||
| 380 | The other window will show the corresponding part of the document. | ||
| 381 | This flag can be toggled from within the *toc* buffer with the `f' key." | ||
| 382 | :group 'reftex-table-of-contents-browser | ||
| 383 | :type 'boolean) | ||
| 384 | |||
| 385 | (defcustom reftex-revisit-to-follow nil | ||
| 386 | "*Non-nil means, follow-mode will revisit files if necessary. | ||
| 387 | When nil, follow-mode will be suspended for stuff in unvisited files." | ||
| 388 | :group 'reftex-table-of-contents-browser | ||
| 389 | :group 'reftex-referencing-labels | ||
| 390 | :type 'boolean) | ||
| 391 | |||
| 392 | (defcustom reftex-toc-mode-hook nil | ||
| 393 | "Mode hook for reftex-toc-mode." | ||
| 394 | :group 'reftex-table-of-contents-browser | ||
| 395 | :type 'hook) | ||
| 396 | |||
| 397 | ;; Label configuration ----------------------------------------------------- | ||
| 398 | |||
| 353 | (defgroup reftex-label-support nil | 399 | (defgroup reftex-label-support nil |
| 354 | "Support for creation, insertion and referencing of labels in LaTeX." | 400 | "Support for creation, insertion and referencing of labels in LaTeX." |
| 355 | :group 'reftex) | 401 | :group 'reftex) |
| @@ -475,9 +521,6 @@ one of its arguments. The elements of each list entry are: | |||
| 475 | text from the default position (t) to derive a label string. This is | 521 | text from the default position (t) to derive a label string. This is |
| 476 | actually used for section labels. | 522 | actually used for section labels. |
| 477 | 523 | ||
| 478 | Setting the variable `reftex-use-text-after-label-as-context' to t | ||
| 479 | overrides the setting here. | ||
| 480 | |||
| 481 | 5. List of magic words which identify a reference to be of this type. | 524 | 5. List of magic words which identify a reference to be of this type. |
| 482 | If the word before point is equal to one of these words when calling | 525 | If the word before point is equal to one of these words when calling |
| 483 | `reftex-reference', the label list offered will be automatically | 526 | `reftex-reference', the label list offered will be automatically |
| @@ -569,19 +612,6 @@ or macro." | |||
| 569 | :group 'reftex-defining-label-environments | 612 | :group 'reftex-defining-label-environments |
| 570 | :type '(repeat (cons (symbol) (regexp)))) | 613 | :type '(repeat (cons (symbol) (regexp)))) |
| 571 | 614 | ||
| 572 | (defcustom reftex-use-text-after-label-as-context nil | ||
| 573 | "*t means, grab context from directly after the \\label{..} macro. | ||
| 574 | This is the fastest method for obtaining context of the label definition, but | ||
| 575 | requires discipline when placing labels. Setting this variable to t takes | ||
| 576 | precedence over the individual settings in `reftex-label-alist'. | ||
| 577 | This variable may be set to t, nil, or a string of label type letters | ||
| 578 | indicating the label types for which it should be true." | ||
| 579 | :group 'reftex-defining-label-environments | ||
| 580 | :set 'reftex-set-dirty | ||
| 581 | :type '(choice | ||
| 582 | (const :tag "on" t) (const :tag "off" nil) | ||
| 583 | (string :tag "Selected label types"))) | ||
| 584 | |||
| 585 | ;; Label insertion | 615 | ;; Label insertion |
| 586 | 616 | ||
| 587 | (defgroup reftex-making-and-inserting-labels nil | 617 | (defgroup reftex-making-and-inserting-labels nil |
| @@ -941,30 +971,6 @@ should return the string to insert into the buffer." | |||
| 941 | :group 'reftex-citation-support | 971 | :group 'reftex-citation-support |
| 942 | :type 'hook) | 972 | :type 'hook) |
| 943 | 973 | ||
| 944 | ;; Table of contents configuration -------------------------------------- | ||
| 945 | |||
| 946 | (defgroup reftex-table-of-contents-browser nil | ||
| 947 | "A multifile table of contents browser." | ||
| 948 | :group 'reftex) | ||
| 949 | |||
| 950 | (defcustom reftex-toc-follow-mode nil | ||
| 951 | "*Non-nil means, point in *toc* buffer will cause other window to follow. | ||
| 952 | The other window will show the corresponding part of the document. | ||
| 953 | This flag can be toggled from within the *toc* buffer with the `f' key." | ||
| 954 | :group 'reftex-table-of-contents-browser | ||
| 955 | :type 'boolean) | ||
| 956 | |||
| 957 | (defcustom reftex-revisit-to-follow nil | ||
| 958 | "*Non-nil means, follow-mode will revisit files if necessary. | ||
| 959 | When nil, follow-mode will be suspended for stuff in unvisited files." | ||
| 960 | :group 'reftex-table-of-contents-browser | ||
| 961 | :group 'reftex-referencing-labels | ||
| 962 | :type 'boolean) | ||
| 963 | |||
| 964 | (defcustom reftex-toc-mode-hook nil | ||
| 965 | "Mode hook for reftex-toc-mode." | ||
| 966 | :group 'reftex-table-of-contents-browser | ||
| 967 | :type 'hook) | ||
| 968 | 974 | ||
| 969 | ;; Viewing Cross References and Citations | 975 | ;; Viewing Cross References and Citations |
| 970 | (defgroup reftex-viewing-cross-references-and-citations nil | 976 | (defgroup reftex-viewing-cross-references-and-citations nil |
| @@ -1015,7 +1021,7 @@ for X-Symbol, but may have other uses as well." | |||
| 1015 | ;; Finding Files -------------------------------------------------------- | 1021 | ;; Finding Files -------------------------------------------------------- |
| 1016 | 1022 | ||
| 1017 | (defgroup reftex-finding-files nil | 1023 | (defgroup reftex-finding-files nil |
| 1018 | "Displaying cross references and citations." | 1024 | "Finding files on search paths." |
| 1019 | :group 'reftex) | 1025 | :group 'reftex) |
| 1020 | 1026 | ||
| 1021 | (defcustom reftex-texpath-environment-variables '("TEXINPUTS") | 1027 | (defcustom reftex-texpath-environment-variables '("TEXINPUTS") |
| @@ -1049,6 +1055,21 @@ See also `reftex-use-external-file-finders'." | |||
| 1049 | :set 'reftex-set-dirty | 1055 | :set 'reftex-set-dirty |
| 1050 | :type '(repeat (string :tag "Specification"))) | 1056 | :type '(repeat (string :tag "Specification"))) |
| 1051 | 1057 | ||
| 1058 | (defcustom reftex-file-extensions '(("tex" . (".tex" ".ltx")) | ||
| 1059 | ("bib" . (".bib"))) | ||
| 1060 | "*Association list with file extensions for different file types. | ||
| 1061 | This is a list of items, each item is like: (TYPE . (DEF-EXT OTHER-EXT ...)) | ||
| 1062 | |||
| 1063 | TYPE: File type like \"bib\" or \"tex\". | ||
| 1064 | DEF-EXT: The default extension for that file type, like \".tex\" or \".bib\". | ||
| 1065 | OTHER-EXT: Any number of other legal extensions for this file type. | ||
| 1066 | |||
| 1067 | When a files is searched and it does not have any of the legal extensions, | ||
| 1068 | we try the default extension first, and then the naked file name." | ||
| 1069 | :group 'reftex-finding-files | ||
| 1070 | :type '(repeat (cons (string :tag "File type") | ||
| 1071 | (repeat (string :tag "Extension"))))) | ||
| 1072 | |||
| 1052 | (defcustom reftex-search-unrecursed-path-first t | 1073 | (defcustom reftex-search-unrecursed-path-first t |
| 1053 | "*Non-nil means, search all specified directories before trying recursion. | 1074 | "*Non-nil means, search all specified directories before trying recursion. |
| 1054 | Thus, in a path \".//:/tex/\", search first \"./\", then \"/tex/\" and then | 1075 | Thus, in a path \".//:/tex/\", search first \"./\", then \"/tex/\" and then |
| @@ -1066,7 +1087,7 @@ Normally, RefTeX searches the paths given in the environment variables | |||
| 1066 | TEXINPUTS and BIBINPUTS to find TeX files and BibTeX database files. | 1087 | TEXINPUTS and BIBINPUTS to find TeX files and BibTeX database files. |
| 1067 | With this option turned on, it calls an external program specified in the | 1088 | With this option turned on, it calls an external program specified in the |
| 1068 | option `reftex-external-file-finders' instead. As a side effect, | 1089 | option `reftex-external-file-finders' instead. As a side effect, |
| 1069 | the variables `reftex-texpath-environment-variables' and | 1090 | the variables `reftex-texpath-environment-variables' and |
| 1070 | `reftex-bibpath-environment-variables' will be ignored." | 1091 | `reftex-bibpath-environment-variables' will be ignored." |
| 1071 | :group 'reftex-finding-files | 1092 | :group 'reftex-finding-files |
| 1072 | :type 'boolean) | 1093 | :type 'boolean) |
| @@ -1075,7 +1096,7 @@ the variables `reftex-texpath-environment-variables' and | |||
| 1075 | ("bib" . "kpsewhich -format=.bib %f")) | 1096 | ("bib" . "kpsewhich -format=.bib %f")) |
| 1076 | "*Association list with external programs to call for finding files. | 1097 | "*Association list with external programs to call for finding files. |
| 1077 | Each entry is a cons cell (TYPE . PROGRAM). | 1098 | Each entry is a cons cell (TYPE . PROGRAM). |
| 1078 | Type is either \"tex\" or \"bib\". PROGRAM is the external program to use with | 1099 | TYPE is either \"tex\" or \"bib\". PROGRAM is the external program to use with |
| 1079 | any arguments. %f will be replaced by the name of the file to be found. | 1100 | any arguments. %f will be replaced by the name of the file to be found. |
| 1080 | Note that these commands will be executed directly, not via a shell. | 1101 | Note that these commands will be executed directly, not via a shell. |
| 1081 | Only relevant when `reftex-use-external-file-finders' is non-nil." | 1102 | Only relevant when `reftex-use-external-file-finders' is non-nil." |
| @@ -1314,7 +1335,7 @@ RefTeX will | |||
| 1314 | 1335 | ||
| 1315 | You may also set the variable itself to t or nil in order to turn all | 1336 | You may also set the variable itself to t or nil in order to turn all |
| 1316 | plug-ins on or off, respectively. | 1337 | plug-ins on or off, respectively. |
| 1317 | \\<LaTeX-mode-map>Supplying labels in new sections and environments aplies when creating | 1338 | \\<LaTeX-mode-map>Supplying labels in new sections and environments applies when creating |
| 1318 | sections with \\[LaTeX-section] and environments with \\[LaTeX-environment]. | 1339 | sections with \\[LaTeX-section] and environments with \\[LaTeX-environment]. |
| 1319 | Supplying macro arguments applies when you insert such a macro interactively | 1340 | Supplying macro arguments applies when you insert such a macro interactively |
| 1320 | with \\[TeX-insert-macro]. | 1341 | with \\[TeX-insert-macro]. |
| @@ -1358,7 +1379,7 @@ construct: \\bbb [xxx] {aaa}." | |||
| 1358 | ;;; Define the formal stuff for a minor mode named RefTeX. | 1379 | ;;; Define the formal stuff for a minor mode named RefTeX. |
| 1359 | ;;; | 1380 | ;;; |
| 1360 | 1381 | ||
| 1361 | (defconst reftex-version "RefTeX version 3.41" | 1382 | (defconst reftex-version "RefTeX version 3.42" |
| 1362 | "Version string for RefTeX.") | 1383 | "Version string for RefTeX.") |
| 1363 | 1384 | ||
| 1364 | (defvar reftex-mode nil | 1385 | (defvar reftex-mode nil |
| @@ -1394,8 +1415,8 @@ capabilities is available with `\\[reftex-toc]'. | |||
| 1394 | Most command have help available on the fly. This help is accessed by | 1415 | Most command have help available on the fly. This help is accessed by |
| 1395 | pressing `?' to any prompt mentioning this feature. | 1416 | pressing `?' to any prompt mentioning this feature. |
| 1396 | 1417 | ||
| 1397 | Extensive documentation about RefTeX is in the file header of `reftex.el'. | 1418 | Extensive documentation about RefTeX is available in Info format. |
| 1398 | You can view this information with `\\[reftex-show-commentary]'. | 1419 | You can view this information with `\\[reftex-info]'. |
| 1399 | 1420 | ||
| 1400 | \\{reftex-mode-map} | 1421 | \\{reftex-mode-map} |
| 1401 | Under X, these and other functions will also be available as `Ref' menu | 1422 | Under X, these and other functions will also be available as `Ref' menu |
| @@ -1407,13 +1428,18 @@ on the menu bar. | |||
| 1407 | (setq reftex-mode (not (or (and (null arg) reftex-mode) | 1428 | (setq reftex-mode (not (or (and (null arg) reftex-mode) |
| 1408 | (<= (prefix-numeric-value arg) 0)))) | 1429 | (<= (prefix-numeric-value arg) 0)))) |
| 1409 | 1430 | ||
| 1410 | ; Add or remove the menu, and run the hook | ||
| 1411 | (if reftex-mode | 1431 | (if reftex-mode |
| 1412 | (progn | 1432 | (progn |
| 1433 | ;; Mode was turned on | ||
| 1413 | (easy-menu-add reftex-mode-menu) | 1434 | (easy-menu-add reftex-mode-menu) |
| 1414 | (and reftex-plug-into-AUCTeX | 1435 | (and reftex-plug-into-AUCTeX |
| 1415 | (reftex-plug-into-AUCTeX)) | 1436 | (reftex-plug-into-AUCTeX)) |
| 1437 | (unless (get 'reftex-auto-view-crossref 'initialized) | ||
| 1438 | (and reftex-auto-view-crossref | ||
| 1439 | (reftex-toggle-auto-view-crossref)) | ||
| 1440 | (put 'reftex-auto-view-crossref 'initialized t)) | ||
| 1416 | (run-hooks 'reftex-mode-hook)) | 1441 | (run-hooks 'reftex-mode-hook)) |
| 1442 | ;; Mode was turned off | ||
| 1417 | (easy-menu-remove reftex-mode-menu))) | 1443 | (easy-menu-remove reftex-mode-menu))) |
| 1418 | 1444 | ||
| 1419 | (if (fboundp 'add-minor-mode) | 1445 | (if (fboundp 'add-minor-mode) |
| @@ -1517,7 +1543,9 @@ on the menu bar. | |||
| 1517 | ((master | 1543 | ((master |
| 1518 | (cond | 1544 | (cond |
| 1519 | ((fboundp 'TeX-master-file) ; AUCTeX is loaded. Use its mechanism. | 1545 | ((fboundp 'TeX-master-file) ; AUCTeX is loaded. Use its mechanism. |
| 1520 | (TeX-master-file t)) | 1546 | (condition-case nil |
| 1547 | (TeX-master-file t) | ||
| 1548 | (error (buffer-file-name)))) | ||
| 1521 | ((boundp 'TeX-master) ; The variable is defined - lets use it. | 1549 | ((boundp 'TeX-master) ; The variable is defined - lets use it. |
| 1522 | (cond | 1550 | (cond |
| 1523 | ((eq TeX-master t) | 1551 | ((eq TeX-master t) |
| @@ -1612,6 +1640,7 @@ on the menu bar. | |||
| 1612 | (defvar reftex-prefix nil) | 1640 | (defvar reftex-prefix nil) |
| 1613 | (defvar reftex-section-levels-all nil) | 1641 | (defvar reftex-section-levels-all nil) |
| 1614 | (defvar reftex-buffers-with-changed-invisibility nil) | 1642 | (defvar reftex-buffers-with-changed-invisibility nil) |
| 1643 | (defvar reftex-callback-fwd t) | ||
| 1615 | 1644 | ||
| 1616 | ;; List of buffers created temporarily for lookup, which should be killed. | 1645 | ;; List of buffers created temporarily for lookup, which should be killed. |
| 1617 | (defvar reftex-buffers-to-kill nil) | 1646 | (defvar reftex-buffers-to-kill nil) |
| @@ -1646,6 +1675,7 @@ on the menu bar. | |||
| 1646 | (member rescan '(t 1 (4) (16)))) | 1675 | (member rescan '(t 1 (4) (16)))) |
| 1647 | ;; The docstruct will change: Remove selection buffers. | 1676 | ;; The docstruct will change: Remove selection buffers. |
| 1648 | (save-excursion | 1677 | (save-excursion |
| 1678 | (reftex-erase-buffer "*toc*") | ||
| 1649 | (reftex-erase-all-selection-buffers))) | 1679 | (reftex-erase-all-selection-buffers))) |
| 1650 | 1680 | ||
| 1651 | (if (and (null (symbol-value reftex-docstruct-symbol)) | 1681 | (if (and (null (symbol-value reftex-docstruct-symbol)) |
| @@ -1762,8 +1792,8 @@ on the menu bar. | |||
| 1762 | (alist (mapcar | 1792 | (alist (mapcar |
| 1763 | (function | 1793 | (function |
| 1764 | (lambda (x) | 1794 | (lambda (x) |
| 1765 | (if (setq tmp (reftex-find-tex-file (nth 2 x) | 1795 | (if (setq tmp (reftex-locate-file (nth 2 x) "tex" |
| 1766 | master-dir)) | 1796 | master-dir)) |
| 1767 | (cons (nth 1 x) tmp) | 1797 | (cons (nth 1 x) tmp) |
| 1768 | (message "Can't find external document %s" | 1798 | (message "Can't find external document %s" |
| 1769 | (nth 2 x)) | 1799 | (nth 2 x)) |
| @@ -1791,7 +1821,7 @@ on the menu bar. | |||
| 1791 | toc-entry next-buf buf) | 1821 | toc-entry next-buf buf) |
| 1792 | 1822 | ||
| 1793 | (catch 'exit | 1823 | (catch 'exit |
| 1794 | (setq file-found (reftex-find-tex-file file master-dir)) | 1824 | (setq file-found (reftex-locate-file file "tex" master-dir)) |
| 1795 | (if (and (not file-found) | 1825 | (if (and (not file-found) |
| 1796 | (setq buf (reftex-get-buffer-visiting file))) | 1826 | (setq buf (reftex-get-buffer-visiting file))) |
| 1797 | (setq file-found (buffer-file-name buf))) | 1827 | (setq file-found (buffer-file-name buf))) |
| @@ -1927,9 +1957,7 @@ on the menu bar. | |||
| 1927 | ;; excluded file | 1957 | ;; excluded file |
| 1928 | nil | 1958 | nil |
| 1929 | ;; find the file | 1959 | ;; find the file |
| 1930 | (reftex-find-bib-file | 1960 | (reftex-locate-file x "bib" master-dir))) |
| 1931 | (if (string-match "\\.bib\\'" x) x (concat x ".bib")) | ||
| 1932 | master-dir))) | ||
| 1933 | files)) | 1961 | files)) |
| 1934 | (delq nil files))))) | 1962 | (delq nil files))))) |
| 1935 | 1963 | ||
| @@ -2126,10 +2154,7 @@ Valid actions are: readable, restore, read, kill, write." | |||
| 2126 | (let* ((env-or-mac (or env-or-mac (reftex-label-location bound))) | 2154 | (let* ((env-or-mac (or env-or-mac (reftex-label-location bound))) |
| 2127 | (typekey (nth 1 (assoc env-or-mac reftex-env-or-mac-alist))) | 2155 | (typekey (nth 1 (assoc env-or-mac reftex-env-or-mac-alist))) |
| 2128 | (file (or file (buffer-file-name))) | 2156 | (file (or file (buffer-file-name))) |
| 2129 | (parse (if (reftex-typekey-check | 2157 | (parse (nth 2 (assoc env-or-mac reftex-env-or-mac-alist))) |
| 2130 | typekey reftex-use-text-after-label-as-context) | ||
| 2131 | nil | ||
| 2132 | (nth 2 (assoc env-or-mac reftex-env-or-mac-alist)))) | ||
| 2133 | (text (reftex-short-context env-or-mac parse reftex-location-start | 2158 | (text (reftex-short-context env-or-mac parse reftex-location-start |
| 2134 | derive)) | 2159 | derive)) |
| 2135 | (in-comment (reftex-in-comment))) | 2160 | (in-comment (reftex-in-comment))) |
| @@ -2201,20 +2226,20 @@ Valid actions are: readable, restore, read, kill, write." | |||
| 2201 | "ILLEGAL VALUE OF PARSE")))) | 2226 | "ILLEGAL VALUE OF PARSE")))) |
| 2202 | 2227 | ||
| 2203 | (defun reftex-nicify-text (text) | 2228 | (defun reftex-nicify-text (text) |
| 2204 | ;; Make TEXT nice for inclusion as context into label menu | 2229 | ;; Make TEXT nice for inclusion as context into label menu. |
| 2205 | ;; remove line breaks and extra white space | 2230 | ;; 1. remove line breaks and extra white space |
| 2206 | (while (string-match "[\n\r\t]\\|[ \t][ \t]+" text) | 2231 | (while (string-match "[\n\r\t]\\|[ \t][ \t]+" text) |
| 2207 | (setq text (replace-match " " nil t text))) | 2232 | (setq text (replace-match " " nil t text))) |
| 2208 | ;; cut before the next `\end{' or `\item' or `\\' | 2233 | ;; 2. cut before the next `\end{' or `\item' or `\\' |
| 2209 | (if (string-match "\\(\\\\end{\\|\\\\item\\|\\\\\\\\\\).*" text) | 2234 | (if (string-match "\\(\\\\end{\\|\\\\item\\|\\\\\\\\\\).*" text) |
| 2210 | (setq text (replace-match "" nil t text))) | 2235 | (setq text (replace-match "" nil t text))) |
| 2211 | ;; kill the embedded label | 2236 | ;; 3. kill the embedded label |
| 2212 | (if (string-match "\\\\label{[^}]*}" text) | 2237 | (if (string-match "\\\\label{[^}]*}" text) |
| 2213 | (setq text (replace-match "" nil t text))) | 2238 | (setq text (replace-match "" nil t text))) |
| 2214 | ;; remove leading garbage | 2239 | ;; 4. remove leading garbage |
| 2215 | (if (string-match "\\`[ }]+" text) | 2240 | (if (string-match "\\`[ }]+" text) |
| 2216 | (setq text (replace-match "" nil t text))) | 2241 | (setq text (replace-match "" nil t text))) |
| 2217 | ;; limit length | 2242 | ;; 5. limit length |
| 2218 | (cond | 2243 | (cond |
| 2219 | ((> (length text) 100) (substring text 0 100)) | 2244 | ((> (length text) 100) (substring text 0 100)) |
| 2220 | ((= (length text) 0) (make-string 1 ?\ )) | 2245 | ((= (length text) 0) (make-string 1 ?\ )) |
| @@ -2273,9 +2298,9 @@ Valid actions are: readable, restore, read, kill, write." | |||
| 2273 | ((match-end 7) | 2298 | ((match-end 7) |
| 2274 | ;; Input or include... | 2299 | ;; Input or include... |
| 2275 | (car | 2300 | (car |
| 2276 | (member (list 'eof (reftex-find-tex-file | 2301 | (member (list 'eof (reftex-locate-file |
| 2277 | (reftex-match-string 7) | 2302 | (reftex-match-string 7) "tex" |
| 2278 | (cdr (assq 'master-dir docstruct)))) | 2303 | (cdr (assq 'master-dir docstruct)))) |
| 2279 | docstruct))) | 2304 | docstruct))) |
| 2280 | ((match-end 9) | 2305 | ((match-end 9) |
| 2281 | (assq 'appendix (symbol-value reftex-docstruct-symbol))) | 2306 | (assq 'appendix (symbol-value reftex-docstruct-symbol))) |
| @@ -2406,7 +2431,7 @@ If optional BOUND is an integer, limit backward searches to that point." | |||
| 2406 | (error nil))) | 2431 | (error nil))) |
| 2407 | 2432 | ||
| 2408 | (defun reftex-context-substring () | 2433 | (defun reftex-context-substring () |
| 2409 | ;; Return up to 100 chars from point | 2434 | ;; Return up to 150 chars from point |
| 2410 | ;; When point is just after a { or [, limit string to matching parenthesis | 2435 | ;; When point is just after a { or [, limit string to matching parenthesis |
| 2411 | (cond | 2436 | (cond |
| 2412 | ((or (= (preceding-char) ?\{) | 2437 | ((or (= (preceding-char) ?\{) |
| @@ -2422,7 +2447,7 @@ If optional BOUND is an integer, limit backward searches to that point." | |||
| 2422 | (1- (point))) | 2447 | (1- (point))) |
| 2423 | (error (point-max)))))) | 2448 | (error (point-max)))))) |
| 2424 | (t | 2449 | (t |
| 2425 | ;; no list - just grab 100 characters | 2450 | ;; no list - just grab 150 characters |
| 2426 | (buffer-substring-no-properties (point) | 2451 | (buffer-substring-no-properties (point) |
| 2427 | (min (+ (point) 150) (point-max)))))) | 2452 | (min (+ (point) 150) (point-max)))))) |
| 2428 | 2453 | ||
| @@ -2767,15 +2792,18 @@ IGNORE-WORDS List of words which should be removed from the string." | |||
| 2767 | string)) | 2792 | string)) |
| 2768 | 2793 | ||
| 2769 | (defun reftex-latin1-to-ascii (string) | 2794 | (defun reftex-latin1-to-ascii (string) |
| 2770 | ;; Translate the upper 127 chars in the ISO1 charset to ASCII equivalents | 2795 | ;; Translate the upper 128 chars in the Latin-1 charset to ASCII equivalents |
| 2771 | (let ((tab "@@@@@@@@@@@@@@@@@@'@@@@@@@@@@@@@ icLxY|S\"ca<--R-o|23'uq..1o>423?AAAAAAACEEEEIIIIDNOOOOOXOUUUUYP3aaaaaaaceeeeiiiidnooooo:ouuuuypy") c) | 2796 | (let ((tab "@@@@@@@@@@@@@@@@@@'@@@@@@@@@@@@@ icLxY|S\"ca<--R-o|23'uq..1o>423?AAAAAAACEEEEIIIIDNOOOOOXOUUUUYP3aaaaaaaceeeeiiiidnooooo:ouuuuypy") |
| 2772 | (loop for i from 0 to (1- (length string)) do | 2797 | (emacsp (not (featurep 'xemacs)))) |
| 2773 | (setq c (aref string i)) | 2798 | (mapconcat |
| 2774 | (cond ((and (> c 127) (< c 256)) ; 8 bit Latin-1 | 2799 | (lambda (c) |
| 2775 | (aset string i (aref tab (- c 128)))) | 2800 | (cond ((and (> c 127) (< c 256)) ; 8 bit Latin-1 |
| 2776 | ((and (> c 2175) (< c 2304)) ; Mule Latin-1, | 2801 | (char-to-string (aref tab (- c 128)))) |
| 2777 | (aset string i (aref tab (- c 2176)))))) ; Std. Emacs only | 2802 | ((and emacsp ; Not for XEmacs |
| 2778 | string)) | 2803 | (> c 2175) (< c 2304)) ; Mule Latin-1 |
| 2804 | (char-to-string (aref tab (- c 2176)))) | ||
| 2805 | (t (char-to-string c)))) | ||
| 2806 | string ""))) | ||
| 2779 | 2807 | ||
| 2780 | (defun reftex-replace-prefix-escapes (prefix) | 2808 | (defun reftex-replace-prefix-escapes (prefix) |
| 2781 | ;; Replace %escapes in a label prefix | 2809 | ;; Replace %escapes in a label prefix |
| @@ -3010,9 +3038,11 @@ When called with 2 C-u prefix args, disable magic word recognition." | |||
| 3010 | (cond | 3038 | (cond |
| 3011 | ((= 0 (buffer-size)) | 3039 | ((= 0 (buffer-size)) |
| 3012 | (let ((buffer-read-only nil)) | 3040 | (let ((buffer-read-only nil)) |
| 3013 | (setq offset (reftex-make-and-insert-label-list | 3041 | (message "Creating Selection Buffer...") |
| 3014 | typekey buf toc files context counter commented | 3042 | (setq offset (reftex-insert-docstruct |
| 3015 | (or here-I-am offset) prefix)))) | 3043 | typekey buf toc t files context counter |
| 3044 | commented | ||
| 3045 | (or here-I-am offset) prefix nil)))) | ||
| 3016 | (here-I-am | 3046 | (here-I-am |
| 3017 | (setq offset (reftex-get-offset buf here-I-am typekey))) | 3047 | (setq offset (reftex-get-offset buf here-I-am typekey))) |
| 3018 | (t (setq offset t))) | 3048 | (t (setq offset t))) |
| @@ -3026,7 +3056,7 @@ When called with 2 C-u prefix args, disable magic word recognition." | |||
| 3026 | reftex-select-label-help | 3056 | reftex-select-label-help |
| 3027 | reftex-select-label-map | 3057 | reftex-select-label-map |
| 3028 | offset | 3058 | offset |
| 3029 | 'reftex-select-label-callback follow)) | 3059 | 'reftex-show-label-location follow)) |
| 3030 | (setq key (car rtn) | 3060 | (setq key (car rtn) |
| 3031 | data (nth 1 rtn) | 3061 | data (nth 1 rtn) |
| 3032 | last-data (nth 2 rtn) | 3062 | last-data (nth 2 rtn) |
| @@ -3159,22 +3189,44 @@ When called with 2 C-u prefix args, disable magic word recognition." | |||
| 3159 | (format " *RefTeX[%s][%d]*" | 3189 | (format " *RefTeX[%s][%d]*" |
| 3160 | type (or index (get reftex-docstruct-symbol ':master-index) 0))) | 3190 | type (or index (get reftex-docstruct-symbol ':master-index) 0))) |
| 3161 | 3191 | ||
| 3162 | (defun reftex-get-offset (buf here-am-I typekey) | 3192 | (defun reftex-get-offset (buf here-am-I &optional typekey toc file) |
| 3163 | ;; Find the correct offset data, like make-and-insert would, but faster. | 3193 | ;; Find the correct offset data, like insert-docstruct would, but faster. |
| 3164 | (save-excursion | 3194 | ;; Buffer BUF knows the correct docstruct to use. |
| 3165 | (set-buffer buf) | 3195 | ;; Basically this finds the first docstruct entry after HERE-I-AM which |
| 3166 | (reftex-access-scan-info) | 3196 | ;; is of allowed type. The optional arguments specify what is allowed. |
| 3167 | (let* ((rest (memq here-am-I (symbol-value reftex-docstruct-symbol))) | 3197 | (catch 'exit |
| 3168 | entry) | 3198 | (save-excursion |
| 3169 | (while (and (setq entry (pop rest)) | 3199 | (set-buffer buf) |
| 3170 | (not (and (stringp (car entry)) | 3200 | (reftex-access-scan-info) |
| 3171 | (equal typekey (nth 1 entry)))))) | 3201 | (let* ((rest (memq here-am-I (symbol-value reftex-docstruct-symbol))) |
| 3172 | entry))) | 3202 | entry) |
| 3173 | 3203 | (while (setq entry (pop rest)) | |
| 3174 | (defun reftex-make-and-insert-label-list | 3204 | (if (or (and typekey |
| 3175 | (typekey0 buf toc files context counter show-commented here-I-am xr-prefix) | 3205 | (stringp (car entry)) |
| 3176 | ;; Insert a menu of all labels in buffer BUF into current buffer. | 3206 | (or (equal typekey " ") |
| 3207 | (equal typekey (nth 1 entry)))) | ||
| 3208 | (and toc (eq (car entry) 'toc)) | ||
| 3209 | (and file | ||
| 3210 | (memq (car entry) '(bof eof file-error)))) | ||
| 3211 | (throw 'exit entry))) | ||
| 3212 | nil)))) | ||
| 3213 | |||
| 3214 | (defun reftex-insert-docstruct | ||
| 3215 | (typekey0 buf toc labels files context counter show-commented | ||
| 3216 | here-I-am xr-prefix toc-buffer) | ||
| 3217 | ;; Insert an excerpt of the docstruct list. | ||
| 3177 | ;; Return the data property of the entry corresponding to HERE-I-AM. | 3218 | ;; Return the data property of the entry corresponding to HERE-I-AM. |
| 3219 | ;; TYPEKEY0 indicated which labels to put into the list. | ||
| 3220 | ;; BUF is the buffer which has the correct docstruct-symbol. | ||
| 3221 | ;; LABELS non-nil meand to include labels into the list. | ||
| 3222 | ;; FILES non-nil menas to display file boundaries. | ||
| 3223 | ;; CONTEXT non-nil meand to include label context. | ||
| 3224 | ;; COUNTER means to count the labels. | ||
| 3225 | ;; SHOW-COMMENTED meand to include also labels which are commented out. | ||
| 3226 | ;; HERE-I-AM is a member of the docstruct list. The function will return | ||
| 3227 | ;; a used member near to this one, as a possible starting point. | ||
| 3228 | ;; XR-PREFIX is the prefix to put in front of labels. | ||
| 3229 | ;; TOC-BUFFER means this is to fill the toc buffer. | ||
| 3178 | (let* ((font (reftex-use-fonts)) | 3230 | (let* ((font (reftex-use-fonts)) |
| 3179 | (cnt 0) | 3231 | (cnt 0) |
| 3180 | (index -1) | 3232 | (index -1) |
| @@ -3195,8 +3247,6 @@ When called with 2 C-u prefix args, disable magic word recognition." | |||
| 3195 | all cell text label typekey note comment master-dir-re | 3247 | all cell text label typekey note comment master-dir-re |
| 3196 | offset from to docstruct-symbol) | 3248 | offset from to docstruct-symbol) |
| 3197 | 3249 | ||
| 3198 | (message "Creating Selection Buffer...") | ||
| 3199 | |||
| 3200 | ;; Pop to buffer buf to get the correct buffer-local variables | 3250 | ;; Pop to buffer buf to get the correct buffer-local variables |
| 3201 | (save-excursion | 3251 | (save-excursion |
| 3202 | (set-buffer buf) | 3252 | (set-buffer buf) |
| @@ -3233,6 +3283,7 @@ When called with 2 C-u prefix args, disable magic word recognition." | |||
| 3233 | ((memq (car cell) '(bof eof file-error)) | 3283 | ((memq (car cell) '(bof eof file-error)) |
| 3234 | ;; Beginning or end of a file | 3284 | ;; Beginning or end of a file |
| 3235 | (when files | 3285 | (when files |
| 3286 | (if (eq offset 'attention) (setq offset cell)) | ||
| 3236 | (insert | 3287 | (insert |
| 3237 | " File " (if (string-match master-dir-re (nth 1 cell)) | 3288 | " File " (if (string-match master-dir-re (nth 1 cell)) |
| 3238 | (substring (nth 1 cell) (match-end 0)) | 3289 | (substring (nth 1 cell) (match-end 0)) |
| @@ -3240,19 +3291,31 @@ When called with 2 C-u prefix args, disable magic word recognition." | |||
| 3240 | (cond ((eq (car cell) 'bof) " starts here\n") | 3291 | (cond ((eq (car cell) 'bof) " starts here\n") |
| 3241 | ((eq (car cell) 'eof) " ends here\n") | 3292 | ((eq (car cell) 'eof) " ends here\n") |
| 3242 | ((eq (car cell) 'file-error) " was not found\n"))) | 3293 | ((eq (car cell) 'file-error) " was not found\n"))) |
| 3294 | (setq to (point)) | ||
| 3243 | (when font | 3295 | (when font |
| 3244 | (put-text-property from (point) | 3296 | (put-text-property from to |
| 3245 | 'face reftex-file-boundary-face)))) | 3297 | 'face reftex-file-boundary-face)) |
| 3298 | (when toc-buffer | ||
| 3299 | (if mouse-face | ||
| 3300 | (put-text-property from (1- to) | ||
| 3301 | 'mouse-face mouse-face)) | ||
| 3302 | (put-text-property from to ':data cell)))) | ||
| 3246 | 3303 | ||
| 3247 | ((eq (car cell) 'toc) | 3304 | ((eq (car cell) 'toc) |
| 3248 | ;; a table of contents entry | 3305 | ;; a table of contents entry |
| 3249 | (when toc | 3306 | (when toc |
| 3307 | (if (eq offset 'attention) (setq offset cell)) | ||
| 3250 | (setq reftex-active-toc cell) | 3308 | (setq reftex-active-toc cell) |
| 3251 | (insert (concat toc-indent (nth 2 cell) "\n")) | 3309 | (insert (concat toc-indent (nth 2 cell) "\n")) |
| 3252 | (setq to (point)) | 3310 | (setq to (point)) |
| 3253 | (when font | 3311 | (when font |
| 3254 | (put-text-property from to | 3312 | (put-text-property from to |
| 3255 | 'face reftex-section-heading-face)) | 3313 | 'face reftex-section-heading-face)) |
| 3314 | (when toc-buffer | ||
| 3315 | (if mouse-face | ||
| 3316 | (put-text-property from (1- to) | ||
| 3317 | 'mouse-face mouse-face)) | ||
| 3318 | (put-text-property from to ':data cell)) | ||
| 3256 | (goto-char to))) | 3319 | (goto-char to))) |
| 3257 | 3320 | ||
| 3258 | ((stringp (car cell)) | 3321 | ((stringp (car cell)) |
| @@ -3268,7 +3331,8 @@ When called with 2 C-u prefix args, disable magic word recognition." | |||
| 3268 | comment (nth 4 cell) | 3331 | comment (nth 4 cell) |
| 3269 | note (nth 5 cell)) | 3332 | note (nth 5 cell)) |
| 3270 | 3333 | ||
| 3271 | (when (and (or (string= typekey typekey0) (string= typekey0 " ")) | 3334 | (when (and labels |
| 3335 | (or (string= typekey typekey0) (string= typekey0 " ")) | ||
| 3272 | (or show-commented (null comment))) | 3336 | (or show-commented (null comment))) |
| 3273 | 3337 | ||
| 3274 | ;; Yes we want this one | 3338 | ;; Yes we want this one |
| @@ -3303,10 +3367,34 @@ When called with 2 C-u prefix args, disable magic word recognition." | |||
| 3303 | (goto-char to))))) | 3367 | (goto-char to))))) |
| 3304 | 3368 | ||
| 3305 | (when (reftex-refontify) | 3369 | (when (reftex-refontify) |
| 3370 | ;; we need to fontify the buffer | ||
| 3306 | (reftex-fontify-select-label-buffer buf)) | 3371 | (reftex-fontify-select-label-buffer buf)) |
| 3307 | (run-hooks 'reftex-display-copied-context-hook) | 3372 | (run-hooks 'reftex-display-copied-context-hook) |
| 3308 | offset)) | 3373 | offset)) |
| 3309 | 3374 | ||
| 3375 | (defun reftex-find-start-point (fallback &rest locations) | ||
| 3376 | ;; Set point to the first available LOCATION. When a LOCATION is a list, | ||
| 3377 | ;; search for such a ':data text property. When it is an integer, | ||
| 3378 | ;; use is as line number. FALLBACK is a buffer position used if everything | ||
| 3379 | ;; else fails. | ||
| 3380 | (catch 'exit | ||
| 3381 | (goto-char (point-min)) | ||
| 3382 | (let (loc pos) | ||
| 3383 | (while locations | ||
| 3384 | (setq loc (pop locations)) | ||
| 3385 | (cond | ||
| 3386 | ((null loc)) | ||
| 3387 | ((listp loc) | ||
| 3388 | (setq pos (text-property-any (point-min) (point-max) ':data loc)) | ||
| 3389 | (when pos | ||
| 3390 | (goto-char pos) | ||
| 3391 | (throw 'exit t))) | ||
| 3392 | ((integerp loc) | ||
| 3393 | (when (<= loc (count-lines (point-min) (point-max))) | ||
| 3394 | (goto-line loc) | ||
| 3395 | (throw 'exit t))))) | ||
| 3396 | (goto-char fallback)))) | ||
| 3397 | |||
| 3310 | (defun reftex-query-label-type () | 3398 | (defun reftex-query-label-type () |
| 3311 | ;; Ask for label type | 3399 | ;; Ask for label type |
| 3312 | (let ((key (reftex-select-with-char | 3400 | (let ((key (reftex-select-with-char |
| @@ -3315,17 +3403,28 @@ When called with 2 C-u prefix args, disable magic word recognition." | |||
| 3315 | (error "No such label type: %s" (char-to-string key))) | 3403 | (error "No such label type: %s" (char-to-string key))) |
| 3316 | (char-to-string key))) | 3404 | (char-to-string key))) |
| 3317 | 3405 | ||
| 3318 | (defun reftex-select-label-callback (data forward no-revisit) | 3406 | (defun reftex-show-label-location (data forward no-revisit |
| 3319 | ;; Callback function called from the label selection in order to | 3407 | &optional stay error) |
| 3320 | ;; show context in another window | 3408 | ;; View the definition site of a label in another window. |
| 3409 | ;; DATA is an entry from the docstruct list. | ||
| 3410 | ;; FORWARD indicates if the label is likely forward from current point. | ||
| 3411 | ;; NO-REVISIT means do not load a file to show this label. | ||
| 3412 | ;; STAY means leave the new window selected. | ||
| 3413 | ;; ERROR means throw an error exception when the label cannot be found. | ||
| 3414 | ;; If ERROR is nil, the return value of this function indicates success. | ||
| 3321 | (let* ((this-window (selected-window)) | 3415 | (let* ((this-window (selected-window)) |
| 3416 | (errorf (if error 'error 'message)) | ||
| 3322 | label file buffer re found) | 3417 | label file buffer re found) |
| 3323 | ;; pop to original buffer in order to get correct variables | 3418 | |
| 3324 | (catch 'exit | 3419 | (catch 'exit |
| 3325 | (setq label (nth 0 data) | 3420 | (setq label (nth 0 data) |
| 3326 | file (nth 3 data)) | 3421 | file (nth 3 data)) |
| 3327 | 3422 | ||
| 3328 | ;; goto the file in another window | 3423 | (unless file |
| 3424 | (funcall errorf "Unknown label - reparse might help") | ||
| 3425 | (throw 'exit nil)) | ||
| 3426 | |||
| 3427 | ;; Goto the file in another window | ||
| 3329 | (setq buffer | 3428 | (setq buffer |
| 3330 | (if no-revisit | 3429 | (if no-revisit |
| 3331 | (reftex-get-buffer-visiting file) | 3430 | (reftex-get-buffer-visiting file) |
| @@ -3336,9 +3435,8 @@ When called with 2 C-u prefix args, disable magic word recognition." | |||
| 3336 | (switch-to-buffer-other-window buffer) | 3435 | (switch-to-buffer-other-window buffer) |
| 3337 | ;; we have got a problem here. The file does not exist. | 3436 | ;; we have got a problem here. The file does not exist. |
| 3338 | ;; Let' get out of here.. | 3437 | ;; Let' get out of here.. |
| 3339 | ;; (ding) | 3438 | (funcall errorf "Label %s not found" label) |
| 3340 | (message reftex-no-follow-message) | 3439 | (throw 'exit nil)) |
| 3341 | (throw 'exit nil)) | ||
| 3342 | 3440 | ||
| 3343 | ;; search for that label | 3441 | ;; search for that label |
| 3344 | (setq re (format reftex-find-label-regexp-format (regexp-quote label))) | 3442 | (setq re (format reftex-find-label-regexp-format (regexp-quote label))) |
| @@ -3348,43 +3446,21 @@ When called with 2 C-u prefix args, disable magic word recognition." | |||
| 3348 | (re-search-backward re nil t))) | 3446 | (re-search-backward re nil t))) |
| 3349 | (unless found | 3447 | (unless found |
| 3350 | (goto-char (point-min)) | 3448 | (goto-char (point-min)) |
| 3351 | (unless (re-search-forward re nil t) | 3449 | (unless (setq found (re-search-forward re nil t)) |
| 3352 | ;; Ooops. Must be in a macro with distributed args. | 3450 | ;; Ooops. Must be in a macro with distributed args. |
| 3353 | (re-search-forward (format reftex-find-label-regexp-format2 | 3451 | (setq found |
| 3354 | (regexp-quote label)) nil t))) | 3452 | (re-search-forward |
| 3355 | (when (match-end 3) | 3453 | (format reftex-find-label-regexp-format2 |
| 3356 | (setq reftex-latex-syntax-table (syntax-table)) | 3454 | (regexp-quote label)) nil t)))) |
| 3357 | (reftex-highlight 0 (match-beginning 3) (match-end 3)) | 3455 | (if (match-end 3) |
| 3358 | (reftex-show-entry (match-beginning 3) (match-end 3)) | 3456 | (progn |
| 3359 | (recenter '(4))) | 3457 | (reftex-highlight 0 (match-beginning 3) (match-end 3)) |
| 3360 | (select-window this-window)))) | 3458 | (reftex-show-entry (match-beginning 3) (match-end 3)) |
| 3361 | |||
| 3362 | (defun reftex-pop-to-label (label file-list &optional mark-to-kill highlight) | ||
| 3363 | ;; Find LABEL in any file in FILE-LIST in another window. | ||
| 3364 | ;; If mark-to-kill is non-nil, mark new buffer for killing. | ||
| 3365 | ;; If HIGHLIGHT is non-nil, highlight the label definition. | ||
| 3366 | (let* ((re1 (format reftex-find-label-regexp-format (regexp-quote label))) | ||
| 3367 | (re2 (format reftex-find-label-regexp-format2 (regexp-quote label))) | ||
| 3368 | (re-list (list re1 re2)) re | ||
| 3369 | (file-list-1 file-list) | ||
| 3370 | file buf) | ||
| 3371 | (catch 'exit | ||
| 3372 | (while (setq re (pop re-list)) | ||
| 3373 | (setq file-list file-list-1) | ||
| 3374 | (while (setq file (pop file-list)) | ||
| 3375 | (unless (setq buf (reftex-get-file-buffer-force file mark-to-kill)) | ||
| 3376 | (error "No such file %s" file)) | ||
| 3377 | (set-buffer buf) | ||
| 3378 | (widen) | ||
| 3379 | (goto-char (point-min)) | ||
| 3380 | (when (re-search-forward re nil t) | ||
| 3381 | (switch-to-buffer-other-window buf) | ||
| 3382 | (goto-char (match-beginning 0)) | ||
| 3383 | (recenter '(4)) | 3459 | (recenter '(4)) |
| 3384 | (if highlight | 3460 | (unless stay (select-window this-window))) |
| 3385 | (reftex-highlight 0 (match-beginning 3) (match-end 3))) | 3461 | (select-window this-window) |
| 3386 | (throw 'exit (selected-window))))) | 3462 | (funcall errorf "Label %s not found" label)) |
| 3387 | (error "Label %s not found" label)))) | 3463 | found))) |
| 3388 | 3464 | ||
| 3389 | (defun reftex-show-entry (beg-hlt end-hlt) | 3465 | (defun reftex-show-entry (beg-hlt end-hlt) |
| 3390 | ;; Show entry if point is hidden | 3466 | ;; Show entry if point is hidden |
| @@ -3471,15 +3547,16 @@ Here are all local bindings. | |||
| 3471 | ============================ | 3547 | ============================ |
| 3472 | n / p next-line / previous-line | 3548 | n / p next-line / previous-line |
| 3473 | SPC Show the corresponding section of the LaTeX document. | 3549 | SPC Show the corresponding section of the LaTeX document. |
| 3474 | TAB Goto the section. | 3550 | TAB Goto the section and keep the *toc* window. |
| 3475 | RET Goto the section and hide the *toc* buffer (also on mouse-2). | 3551 | RET Goto the section and hide the *toc* window (also on mouse-2). |
| 3476 | q / Q Hide/Kill *toc* buffer, return to position of last reftex-toc command. | 3552 | q / Q Hide/Kill *toc* buffer, return to position of last reftex-toc command. |
| 3477 | f / g Toggle follow mode on and off / Refresh *toc* buffer. | 3553 | l c i Toggle display of [l]abels, [c]ontext, [i]nclude file borders. |
| 3478 | r / R Reparse the LaTeX document / Reparse entire LaTeX document. | 3554 | f / g Toggle follow mode on and off / Refresh *toc* buffer. |
| 3555 | r / R Reparse the LaTeX document / Reparse entire LaTeX document. | ||
| 3479 | . In other window, show position from where `reftex-toc' was called. | 3556 | . In other window, show position from where `reftex-toc' was called. |
| 3480 | x Switch to TOC of external document (with LaTeX package `xr').") | 3557 | x Switch to TOC of external document (with LaTeX package `xr').") |
| 3481 | 3558 | ||
| 3482 | (defun reftex-toc () | 3559 | (defun reftex-toc (&optional rebuild) |
| 3483 | "Show the table of contents for the current document. | 3560 | "Show the table of contents for the current document. |
| 3484 | When called with a raw C-u prefix, rescan the document first." | 3561 | When called with a raw C-u prefix, rescan the document first." |
| 3485 | 3562 | ||
| @@ -3501,20 +3578,18 @@ When called with a raw C-u prefix, rescan the document first." | |||
| 3501 | ;; Ensure access to scanning info and rescan buffer if prefix are is '(4) | 3578 | ;; Ensure access to scanning info and rescan buffer if prefix are is '(4) |
| 3502 | (reftex-access-scan-info current-prefix-arg) | 3579 | (reftex-access-scan-info current-prefix-arg) |
| 3503 | 3580 | ||
| 3504 | (let* ((all (symbol-value reftex-docstruct-symbol)) | 3581 | (let* ((this-buf (current-buffer)) |
| 3505 | (xr-data (assq 'xr all)) | 3582 | (xr-data (assq 'xr (symbol-value reftex-docstruct-symbol))) |
| 3506 | (xr-alist (cons (cons "" (buffer-file-name)) (nth 1 xr-data))) | 3583 | (xr-alist (cons (cons "" (buffer-file-name)) (nth 1 xr-data))) |
| 3507 | (where (reftex-nearest-section)) | 3584 | (here-I-am (if rebuild |
| 3508 | (mouse-face | 3585 | (get 'reftex-toc ':reftex-data) |
| 3509 | (if (memq reftex-highlight-selection '(mouse both)) | 3586 | (car (reftex-where-am-I)))) |
| 3510 | reftex-mouse-selected-face | 3587 | offset) |
| 3511 | nil)) | ||
| 3512 | (fontify (reftex-use-fonts)) | ||
| 3513 | toc1 cell startpos) | ||
| 3514 | 3588 | ||
| 3515 | (if (get-buffer-window "*toc*") | 3589 | (if (get-buffer-window "*toc*") |
| 3516 | (select-window (get-buffer-window "*toc*")) | 3590 | (select-window (get-buffer-window "*toc*")) |
| 3517 | (when (< (window-height) (* 2 window-min-height)) | 3591 | (when (or (not reftex-toc-keep-other-windows) |
| 3592 | (< (window-height) (* 2 window-min-height))) | ||
| 3518 | (delete-other-windows)) | 3593 | (delete-other-windows)) |
| 3519 | (setq reftex-last-window-height (window-height)) ; remember | 3594 | (setq reftex-last-window-height (window-height)) ; remember |
| 3520 | (split-window) | 3595 | (split-window) |
| @@ -3524,60 +3599,54 @@ When called with a raw C-u prefix, rescan the document first." | |||
| 3524 | (or (eq major-mode 'reftex-toc-mode) (reftex-toc-mode)) | 3599 | (or (eq major-mode 'reftex-toc-mode) (reftex-toc-mode)) |
| 3525 | 3600 | ||
| 3526 | (cond | 3601 | (cond |
| 3527 | ;; buffer is empty - fill it with the table of contents | ||
| 3528 | ((= (buffer-size) 0) | 3602 | ((= (buffer-size) 0) |
| 3603 | ;; buffer is empty - fill it with the table of contents | ||
| 3529 | (message "Building *toc* buffer...") | 3604 | (message "Building *toc* buffer...") |
| 3530 | 3605 | ||
| 3531 | (setq buffer-read-only nil) | 3606 | (setq buffer-read-only nil) |
| 3532 | (insert (format | 3607 | (insert (format |
| 3533 | "TABLE-OF-CONTENTS on %s | 3608 | "TABLE-OF-CONTENTS on %s |
| 3534 | SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [f]ollow-mode e[x]tern [?]Help | 3609 | SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [l]abels [f]ollow [x]r [?]Help |
| 3535 | ------------------------------------------------------------------------------- | 3610 | ------------------------------------------------------------------------------ |
| 3536 | " (abbreviate-file-name reftex-last-toc-master))) | 3611 | " (abbreviate-file-name reftex-last-toc-master))) |
| 3537 | (setq startpos (point)) | ||
| 3538 | 3612 | ||
| 3539 | (if (reftex-use-fonts) | 3613 | (if (reftex-use-fonts) |
| 3540 | (put-text-property 1 (point) 'face reftex-toc-header-face)) | 3614 | (put-text-property 1 (point) 'face reftex-toc-header-face)) |
| 3541 | (put-text-property 1 (point) 'intangible t) | 3615 | (put-text-property 1 (point) 'intangible t) |
| 3542 | (put-text-property 1 2 'xr-alist xr-alist) | 3616 | (put-text-property 1 2 'xr-alist xr-alist) |
| 3543 | 3617 | ||
| 3544 | (while all | 3618 | (setq offset |
| 3545 | (setq cell (car all) | 3619 | (reftex-insert-docstruct |
| 3546 | all (cdr all)) | 3620 | " " |
| 3547 | (when (eq (car cell) 'toc) | 3621 | this-buf |
| 3548 | (setq toc1 (concat (nth 2 cell) "\n")) | 3622 | t ; toc |
| 3549 | (put-text-property 0 (length toc1) 'toc cell toc1) | 3623 | reftex-toc-include-labels |
| 3550 | (when fontify | 3624 | reftex-toc-include-file-boundaries |
| 3551 | (put-text-property 0 (length toc1) | 3625 | reftex-toc-include-context |
| 3552 | 'face reftex-section-heading-face toc1)) | 3626 | nil ; counter |
| 3553 | (when mouse-face | 3627 | nil ; commented |
| 3554 | (put-text-property 0 (1- (length toc1)) | 3628 | here-I-am "" t)) |
| 3555 | 'mouse-face mouse-face toc1)) | 3629 | |
| 3556 | (insert toc1))) | ||
| 3557 | |||
| 3558 | (backward-delete-char 1) | ||
| 3559 | |||
| 3560 | (run-hooks 'reftex-display-copied-context-hook) | 3630 | (run-hooks 'reftex-display-copied-context-hook) |
| 3561 | (message "Building *toc* buffer...done.") | 3631 | (message "Building *toc* buffer...done.") |
| 3562 | (setq buffer-read-only t)) | 3632 | (setq buffer-read-only t)) |
| 3563 | (t | 3633 | (t |
| 3634 | ;; Only compute the offset | ||
| 3635 | (setq offset | ||
| 3636 | (or (reftex-get-offset this-buf here-I-am | ||
| 3637 | (if reftex-toc-include-labels " " nil) | ||
| 3638 | t | ||
| 3639 | reftex-toc-include-file-boundaries) | ||
| 3640 | (reftex-last-assoc-before-elt | ||
| 3641 | 'toc here-I-am | ||
| 3642 | (symbol-value reftex-docstruct-symbol)))) | ||
| 3643 | (put 'reftex-toc ':reftex-line 3) | ||
| 3564 | (goto-line 3) | 3644 | (goto-line 3) |
| 3565 | (beginning-of-line) | 3645 | (beginning-of-line))) |
| 3566 | (setq startpos (point)))) | ||
| 3567 | |||
| 3568 | ;; Find the correct section | ||
| 3569 | (goto-char (point-max)) | ||
| 3570 | (beginning-of-line) | ||
| 3571 | (while (and (> (point) startpos) | ||
| 3572 | (not (eq (get-text-property (point) 'toc) where))) | ||
| 3573 | (beginning-of-line 0)) | ||
| 3574 | (setq reftex-last-follow-point (point)))) | ||
| 3575 | 3646 | ||
| 3576 | (defun reftex-nearest-section () | 3647 | ;; Find the correct starting point |
| 3577 | ;; Return (file . find) of nearest section command | 3648 | (reftex-find-start-point (point) offset (get 'reftex-toc ':reftex-line)) |
| 3578 | (let* ((here-I-am (car (reftex-where-am-I)))) | 3649 | (setq reftex-last-follow-point (point)))) |
| 3579 | (reftex-last-assoc-before-elt | ||
| 3580 | 'toc here-I-am (symbol-value reftex-docstruct-symbol)))) | ||
| 3581 | 3650 | ||
| 3582 | (defun reftex-toc-pre-command-hook () | 3651 | (defun reftex-toc-pre-command-hook () |
| 3583 | ;; used as pre command hook in *toc* buffer | 3652 | ;; used as pre command hook in *toc* buffer |
| @@ -3586,29 +3655,32 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [f]ollow-mode e[x]tern [?]Help | |||
| 3586 | 3655 | ||
| 3587 | (defun reftex-toc-post-command-hook () | 3656 | (defun reftex-toc-post-command-hook () |
| 3588 | ;; used in the post-command-hook for the *toc* buffer | 3657 | ;; used in the post-command-hook for the *toc* buffer |
| 3589 | (and (> (point) 1) | 3658 | (when (get-text-property (point) ':data) |
| 3590 | (memq reftex-highlight-selection '(cursor both)) | 3659 | (put 'reftex-toc ':reftex-data (get-text-property (point) ':data)) |
| 3591 | (save-excursion | 3660 | (and (> (point) 1) |
| 3592 | (reftex-highlight 1 | 3661 | (not (get-text-property (point) 'intangible)) |
| 3593 | (progn (beginning-of-line) (point)) | 3662 | (memq reftex-highlight-selection '(cursor both)) |
| 3594 | (progn (end-of-line) (point))))) | 3663 | (reftex-highlight 1 |
| 3595 | (cond | 3664 | (or (previous-single-property-change (1+ (point)) ':data) |
| 3596 | ((integerp reftex-toc-follow-mode) | 3665 | (point-min)) |
| 3597 | ;; remove delayed action | 3666 | (or (next-single-property-change (point) ':data) |
| 3598 | (setq reftex-toc-follow-mode t)) | 3667 | (point-max))))) |
| 3599 | ((and reftex-toc-follow-mode | 3668 | (if (integerp reftex-toc-follow-mode) |
| 3600 | (not (equal reftex-last-follow-point (point)))) | 3669 | ;; remove delayed action |
| 3601 | ;; show context in other window | 3670 | (setq reftex-toc-follow-mode t) |
| 3602 | (setq reftex-last-follow-point (point)) | 3671 | (and reftex-toc-follow-mode |
| 3603 | (condition-case nil | 3672 | (not (equal reftex-last-follow-point (point))) |
| 3604 | (reftex-toc-visit-line nil (not reftex-revisit-to-follow)) | 3673 | ;; show context in other window |
| 3605 | (error t))))) | 3674 | (setq reftex-last-follow-point (point)) |
| 3675 | (condition-case nil | ||
| 3676 | (reftex-toc-visit-location nil (not reftex-revisit-to-follow)) | ||
| 3677 | (error t))))) | ||
| 3606 | 3678 | ||
| 3607 | (defun reftex-re-enlarge () | 3679 | (defun reftex-re-enlarge () |
| 3608 | ;; Enlarge windiw to a remembered size | 3680 | ;; Enlarge windiw to a remembered size |
| 3609 | (enlarge-window | 3681 | (enlarge-window |
| 3610 | (max 0 (- (or reftex-last-window-height (window-height)) | 3682 | (max 0 (- (or reftex-last-window-height (window-height)) |
| 3611 | (window-height))))) | 3683 | (window-height))))) |
| 3612 | 3684 | ||
| 3613 | (defun reftex-toc-show-help () | 3685 | (defun reftex-toc-show-help () |
| 3614 | "Show a summary of special key bindings." | 3686 | "Show a summary of special key bindings." |
| @@ -3619,34 +3691,65 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [f]ollow-mode e[x]tern [?]Help | |||
| 3619 | (if reftex-toc-follow-mode | 3691 | (if reftex-toc-follow-mode |
| 3620 | (setq reftex-toc-follow-mode 1))) | 3692 | (setq reftex-toc-follow-mode 1))) |
| 3621 | 3693 | ||
| 3694 | (defun reftex-toc-next (&optional arg) | ||
| 3695 | "Move to next selectable item." | ||
| 3696 | (interactive "p") | ||
| 3697 | (setq reftex-callback-fwd t) | ||
| 3698 | (or (eobp) (forward-char 1)) | ||
| 3699 | (goto-char (or (next-single-property-change (point) ':data) | ||
| 3700 | (point)))) | ||
| 3701 | (defun reftex-toc-previous (&optional arg) | ||
| 3702 | "Move to previous selectable item." | ||
| 3703 | (interactive "p") | ||
| 3704 | (setq reftex-callback-fwd nil) | ||
| 3705 | (goto-char (or (previous-single-property-change (point) ':data) | ||
| 3706 | (point)))) | ||
| 3622 | (defun reftex-toc-toggle-follow () | 3707 | (defun reftex-toc-toggle-follow () |
| 3623 | "Toggle toc-follow mode. (It is not really a mode, just a flag)." | 3708 | "Toggle follow (other window follows with context)." |
| 3624 | (interactive) | 3709 | (interactive) |
| 3625 | (setq reftex-last-follow-point -1) | 3710 | (setq reftex-last-follow-point -1) |
| 3626 | (setq reftex-toc-follow-mode (not reftex-toc-follow-mode))) | 3711 | (setq reftex-toc-follow-mode (not reftex-toc-follow-mode))) |
| 3712 | (defun reftex-toc-toggle-file-boundary () | ||
| 3713 | "Toggle inclusion of file boundaries in *toc* buffer." | ||
| 3714 | (interactive) | ||
| 3715 | (setq reftex-toc-include-file-boundaries | ||
| 3716 | (not reftex-toc-include-file-boundaries)) | ||
| 3717 | (reftex-toc-revert)) | ||
| 3718 | (defun reftex-toc-toggle-labels () | ||
| 3719 | "Toggle inclusion of labels in *toc* buffer." | ||
| 3720 | (interactive) | ||
| 3721 | (setq reftex-toc-include-labels (not reftex-toc-include-labels)) | ||
| 3722 | (reftex-toc-revert)) | ||
| 3723 | (defun reftex-toc-toggle-context () | ||
| 3724 | "Toggle inclusion of label context in *toc* buffer. | ||
| 3725 | Label context is only displayed when the labels are there as well." | ||
| 3726 | (interactive) | ||
| 3727 | (setq reftex-toc-include-context (not reftex-toc-include-context)) | ||
| 3728 | (reftex-toc-revert)) | ||
| 3627 | (defun reftex-toc-view-line () | 3729 | (defun reftex-toc-view-line () |
| 3628 | "View document location in other window." | 3730 | "View document location in other window." |
| 3629 | (interactive) | 3731 | (interactive) |
| 3630 | (reftex-toc-visit-line)) | 3732 | (reftex-toc-visit-location)) |
| 3631 | (defun reftex-toc-mouse-view-line (ev) | 3733 | (defun reftex-toc-mouse-view-line (ev) |
| 3632 | "View document location in other window." | 3734 | "View document location in other window." |
| 3633 | (interactive "e") | 3735 | (interactive "e") |
| 3634 | (mouse-set-point ev) | 3736 | (mouse-set-point ev) |
| 3635 | (reftex-toc-visit-line)) | 3737 | (reftex-toc-visit-location)) |
| 3636 | (defun reftex-toc-goto-line-and-hide () | 3738 | (defun reftex-toc-goto-line-and-hide () |
| 3637 | "Go to document location in other window. Hide the *toc* window." | 3739 | "Go to document location in other window. Hide the *toc* window." |
| 3638 | (interactive) | 3740 | (interactive) |
| 3639 | (reftex-toc-visit-line 'hide)) | 3741 | (reftex-toc-visit-location 'hide)) |
| 3640 | (defun reftex-toc-goto-line () | 3742 | (defun reftex-toc-goto-line () |
| 3641 | "Go to document location in other window. Hide the *toc* window." | 3743 | "Go to document location in other window. *toc* window stays." |
| 3642 | (interactive) | 3744 | (interactive) |
| 3643 | (reftex-toc-visit-line t)) | 3745 | (reftex-toc-visit-location t)) |
| 3644 | (defun reftex-toc-mouse-goto-line-and-hide (ev) | 3746 | (defun reftex-toc-mouse-goto-line-and-hide (ev) |
| 3645 | "Go to document location in other window. Hide the *toc* window." | 3747 | "Go to document location in other window. Hide the *toc* window." |
| 3646 | (interactive "e") | 3748 | (interactive "e") |
| 3647 | (mouse-set-point ev) | 3749 | (mouse-set-point ev) |
| 3648 | (reftex-toc-visit-line 'hide)) | 3750 | (reftex-toc-visit-location 'hide)) |
| 3649 | (defun reftex-toc-show-insertion-point () | 3751 | (defun reftex-toc-show-calling-point () |
| 3752 | "Show point where reftex-toc was called from." | ||
| 3650 | (interactive) | 3753 | (interactive) |
| 3651 | (let ((this-window (selected-window))) | 3754 | (let ((this-window (selected-window))) |
| 3652 | (unwind-protect | 3755 | (unwind-protect |
| @@ -3675,13 +3778,19 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [f]ollow-mode e[x]tern [?]Help | |||
| 3675 | "Regenerate the *toc* buffer by reparsing file of section at point." | 3778 | "Regenerate the *toc* buffer by reparsing file of section at point." |
| 3676 | (interactive) | 3779 | (interactive) |
| 3677 | (if reftex-enable-partial-scans | 3780 | (if reftex-enable-partial-scans |
| 3678 | (let ((file (nth 3 (get-text-property (point) 'toc)))) | 3781 | (let* ((data (get-text-property (point) ':data)) |
| 3782 | (what (car data)) | ||
| 3783 | (file (cond ((eq what 'toc) (nth 3 data)) | ||
| 3784 | ((memq what '(eof bof file-error)) (nth 1 data)) | ||
| 3785 | ((stringp what) (nth 3 data)))) | ||
| 3786 | (line (+ (count-lines (point-min) (point)) (if (bolp) 1 0)))) | ||
| 3679 | (if (not file) | 3787 | (if (not file) |
| 3680 | (error "Don't know which file to rescan. Try `R'") | 3788 | (error "Don't know which file to rescan. Try `R'") |
| 3789 | (put 'reftex-toc ':reftex-line line) | ||
| 3681 | (switch-to-buffer-other-window | 3790 | (switch-to-buffer-other-window |
| 3682 | (reftex-get-file-buffer-force file)) | 3791 | (reftex-get-file-buffer-force file)) |
| 3683 | (setq current-prefix-arg '(4)) | 3792 | (setq current-prefix-arg '(4)) |
| 3684 | (reftex-toc))) | 3793 | (reftex-toc t))) |
| 3685 | (reftex-toc-Rescan)) | 3794 | (reftex-toc-Rescan)) |
| 3686 | (reftex-kill-temporary-buffers)) | 3795 | (reftex-kill-temporary-buffers)) |
| 3687 | (defun reftex-toc-Rescan (&rest ignore) | 3796 | (defun reftex-toc-Rescan (&rest ignore) |
| @@ -3690,7 +3799,7 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [f]ollow-mode e[x]tern [?]Help | |||
| 3690 | (switch-to-buffer-other-window | 3799 | (switch-to-buffer-other-window |
| 3691 | (reftex-get-file-buffer-force reftex-last-toc-file)) | 3800 | (reftex-get-file-buffer-force reftex-last-toc-file)) |
| 3692 | (setq current-prefix-arg '(16)) | 3801 | (setq current-prefix-arg '(16)) |
| 3693 | (reftex-toc)) | 3802 | (reftex-toc t)) |
| 3694 | (defun reftex-toc-revert (&rest ignore) | 3803 | (defun reftex-toc-revert (&rest ignore) |
| 3695 | "Regenerate the *toc* from the internal lists." | 3804 | "Regenerate the *toc* from the internal lists." |
| 3696 | (interactive) | 3805 | (interactive) |
| @@ -3698,7 +3807,7 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [f]ollow-mode e[x]tern [?]Help | |||
| 3698 | (reftex-get-file-buffer-force reftex-last-toc-file)) | 3807 | (reftex-get-file-buffer-force reftex-last-toc-file)) |
| 3699 | (reftex-erase-buffer "*toc*") | 3808 | (reftex-erase-buffer "*toc*") |
| 3700 | (setq current-prefix-arg nil) | 3809 | (setq current-prefix-arg nil) |
| 3701 | (reftex-toc)) | 3810 | (reftex-toc t)) |
| 3702 | (defun reftex-toc-external (&rest ignore) | 3811 | (defun reftex-toc-external (&rest ignore) |
| 3703 | "Switch to table of contents of an external document." | 3812 | "Switch to table of contents of an external document." |
| 3704 | (interactive) | 3813 | (interactive) |
| @@ -3714,67 +3823,51 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [f]ollow-mode e[x]tern [?]Help | |||
| 3714 | (message "") | 3823 | (message "") |
| 3715 | (message "Switched document")))) | 3824 | (message "Switched document")))) |
| 3716 | 3825 | ||
| 3717 | (defun reftex-toc-visit-line (&optional final no-revisit) | 3826 | (defun reftex-toc-visit-location (&optional final no-revisit) |
| 3718 | ;; Visit the tex file corresponding to the toc entry on the current line. | 3827 | ;; Visit the tex file corresponding to the toc entry on the current line. |
| 3719 | ;; If FINAL is t, stay there | 3828 | ;; If FINAL is t, stay there |
| 3720 | ;; If FINAL is 'hide, hide the *toc* window. | 3829 | ;; If FINAL is 'hide, hide the *toc* window. |
| 3721 | ;; Otherwise, move cursor back into *toc* window. | 3830 | ;; Otherwise, move cursor back into *toc* window. |
| 3831 | ;; NO-REVISIT means don't visit files, just use live biffers. | ||
| 3722 | ;; This function is pretty clever about finding back a section heading, | 3832 | ;; This function is pretty clever about finding back a section heading, |
| 3723 | ;; even if the buffer is not live, or things like outline, x-symbol etc. | 3833 | ;; even if the buffer is not live, or things like outline, x-symbol etc. |
| 3724 | ;; have been active. | 3834 | ;; have been active. |
| 3725 | 3835 | ||
| 3726 | (let* ((toc (get-text-property (point) 'toc)) | 3836 | (let* ((toc (get-text-property (point) ':data)) |
| 3727 | (file (nth 3 toc)) | ||
| 3728 | (marker (nth 4 toc)) | ||
| 3729 | (level (nth 5 toc)) | ||
| 3730 | (literal (nth 7 toc)) | ||
| 3731 | (emergency-point (nth 8 toc)) | ||
| 3732 | (toc-window (selected-window)) | 3837 | (toc-window (selected-window)) |
| 3733 | show-window show-buffer match) | 3838 | show-window show-buffer match) |
| 3734 | 3839 | ||
| 3735 | (unless toc (error "Don't know which toc line to visit")) | 3840 | (unless toc (error "Don't know which toc line to visit")) |
| 3736 | 3841 | ||
| 3737 | (setq match | 3842 | (cond |
| 3738 | (cond | 3843 | |
| 3739 | ((and (markerp marker) (marker-buffer marker)) | 3844 | ((eq (car toc) 'toc) |
| 3740 | ;; Buffer is still live and we have the marker. Should be easy. | 3845 | ;; a toc entry |
| 3741 | (switch-to-buffer-other-window (marker-buffer marker)) | 3846 | (setq match (reftex-toc-find-section toc no-revisit))) |
| 3742 | (goto-char (marker-position marker)) | 3847 | |
| 3743 | (or (looking-at (regexp-quote literal)) | 3848 | ((memq (car toc) '(bof eof)) |
| 3744 | (looking-at (reftex-make-regexp-allow-for-ctrl-m literal)) | 3849 | ;; A file entry |
| 3745 | (looking-at (reftex-make-desperate-section-regexp literal)) | 3850 | (setq match |
| 3746 | (looking-at (concat "\\\\" | 3851 | (let ((where (car toc)) |
| 3747 | (regexp-quote | 3852 | (file (nth 1 toc))) |
| 3748 | (car (rassq level | 3853 | (if (or (not no-revisit) (reftex-get-buffer-visiting file)) |
| 3749 | reftex-section-levels-all))) | 3854 | (progn |
| 3750 | "[[{]")))) | 3855 | (switch-to-buffer-other-window |
| 3751 | ((or (not no-revisit) | 3856 | (reftex-get-file-buffer-force file nil)) |
| 3752 | (reftex-get-buffer-visiting file)) | 3857 | (goto-char (if (eq where 'bof) (point-min) (point-max)))) |
| 3753 | ;; Marker is lost. Use the backup method. | 3858 | (message reftex-no-follow-message) nil)))) |
| 3754 | (switch-to-buffer-other-window | 3859 | |
| 3755 | (reftex-get-file-buffer-force file nil)) | 3860 | ((stringp (car toc)) |
| 3756 | (goto-char (or emergency-point (point-min))) | 3861 | ;; a label |
| 3757 | (or (looking-at (regexp-quote literal)) | 3862 | (setq match (reftex-show-label-location toc reftex-callback-fwd |
| 3758 | (let ((pos (point))) | 3863 | no-revisit t)))) |
| 3759 | (re-search-backward "\\`\\|[\r\n][ \t]*[\r\n]" nil t) | ||
| 3760 | (or (reftex-nearest-match (regexp-quote literal) pos) | ||
| 3761 | (reftex-nearest-match | ||
| 3762 | (reftex-make-regexp-allow-for-ctrl-m literal) pos) | ||
| 3763 | (reftex-nearest-match | ||
| 3764 | (reftex-make-desperate-section-regexp literal) pos))))) | ||
| 3765 | (t (message reftex-no-follow-message) nil) | ||
| 3766 | )) | ||
| 3767 | 3864 | ||
| 3768 | (setq show-window (selected-window) | 3865 | (setq show-window (selected-window) |
| 3769 | show-buffer (current-buffer)) | 3866 | show-buffer (current-buffer)) |
| 3770 | 3867 | ||
| 3771 | (unless match | 3868 | (unless match |
| 3772 | (select-window toc-window) | 3869 | (select-window toc-window) |
| 3773 | (error "Cannot find line")) | 3870 | (error "Cannot find location")) |
| 3774 | |||
| 3775 | (goto-char (match-beginning 0)) | ||
| 3776 | (recenter 1) | ||
| 3777 | (reftex-highlight 0 (match-beginning 0) (match-end 0) (current-buffer)) | ||
| 3778 | 3871 | ||
| 3779 | (select-window toc-window) | 3872 | (select-window toc-window) |
| 3780 | 3873 | ||
| @@ -3790,6 +3883,48 @@ SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [f]ollow-mode e[x]tern [?]Help | |||
| 3790 | (reftex-re-enlarge)) | 3883 | (reftex-re-enlarge)) |
| 3791 | (t nil)))) | 3884 | (t nil)))) |
| 3792 | 3885 | ||
| 3886 | (defun reftex-toc-find-section (toc &optional no-revisit) | ||
| 3887 | (let* ((file (nth 3 toc)) | ||
| 3888 | (marker (nth 4 toc)) | ||
| 3889 | (level (nth 5 toc)) | ||
| 3890 | (literal (nth 7 toc)) | ||
| 3891 | (emergency-point (nth 8 toc)) | ||
| 3892 | (match | ||
| 3893 | (cond | ||
| 3894 | ((and (markerp marker) (marker-buffer marker)) | ||
| 3895 | ;; Buffer is still live and we have the marker. Should be easy. | ||
| 3896 | (switch-to-buffer-other-window (marker-buffer marker)) | ||
| 3897 | (goto-char (marker-position marker)) | ||
| 3898 | (or (looking-at (regexp-quote literal)) | ||
| 3899 | (looking-at (reftex-make-regexp-allow-for-ctrl-m literal)) | ||
| 3900 | (looking-at (reftex-make-desperate-section-regexp literal)) | ||
| 3901 | (looking-at (concat "\\\\" | ||
| 3902 | (regexp-quote | ||
| 3903 | (car | ||
| 3904 | (rassq level | ||
| 3905 | reftex-section-levels-all))) | ||
| 3906 | "[[{]")))) | ||
| 3907 | ((or (not no-revisit) | ||
| 3908 | (reftex-get-buffer-visiting file)) | ||
| 3909 | ;; Marker is lost. Use the backup method. | ||
| 3910 | (switch-to-buffer-other-window | ||
| 3911 | (reftex-get-file-buffer-force file nil)) | ||
| 3912 | (goto-char (or emergency-point (point-min))) | ||
| 3913 | (or (looking-at (regexp-quote literal)) | ||
| 3914 | (let ((pos (point))) | ||
| 3915 | (re-search-backward "\\`\\|[\r\n][ \t]*[\r\n]" nil t) | ||
| 3916 | (or (reftex-nearest-match (regexp-quote literal) pos) | ||
| 3917 | (reftex-nearest-match | ||
| 3918 | (reftex-make-regexp-allow-for-ctrl-m literal) pos) | ||
| 3919 | (reftex-nearest-match | ||
| 3920 | (reftex-make-desperate-section-regexp literal) pos))))) | ||
| 3921 | (t (message reftex-no-follow-message) nil)))) | ||
| 3922 | (when match | ||
| 3923 | (goto-char (match-beginning 0)) | ||
| 3924 | (if (not (= (point) (point-max))) (recenter 1)) | ||
| 3925 | (reftex-highlight 0 (match-beginning 0) (match-end 0) (current-buffer))) | ||
| 3926 | match)) | ||
| 3927 | |||
| 3793 | (defun reftex-make-desperate-section-regexp (old) | 3928 | (defun reftex-make-desperate-section-regexp (old) |
| 3794 | ;; Return a regexp which will still match a section statement even if | 3929 | ;; Return a regexp which will still match a section statement even if |
| 3795 | ;; x-symbol or isotex or the like have been at work in the mean time. | 3930 | ;; x-symbol or isotex or the like have been at work in the mean time. |
| @@ -3952,10 +4087,12 @@ During a selection process, these are the local bindings. | |||
| 3952 | (split-string | 4087 | (split-string |
| 3953 | (completing-read | 4088 | (completing-read |
| 3954 | "RegExp [ && RegExp...]: " | 4089 | "RegExp [ && RegExp...]: " |
| 3955 | (if (fboundp 'LaTeX-bibitem-list) | 4090 | (if reftex-mode |
| 3956 | (LaTeX-bibitem-list) | 4091 | (if (fboundp 'LaTeX-bibitem-list) |
| 3957 | (cdr (assoc 'bibview-cache | 4092 | (LaTeX-bibitem-list) |
| 3958 | (symbol-value reftex-docstruct-symbol)))) | 4093 | (cdr (assoc 'bibview-cache |
| 4094 | (symbol-value reftex-docstruct-symbol)))) | ||
| 4095 | nil) | ||
| 3959 | nil nil nil 'reftex-cite-regexp-hist) | 4096 | nil nil nil 'reftex-cite-regexp-hist) |
| 3960 | "[ \t]*&&[ \t]*")) | 4097 | "[ \t]*&&[ \t]*")) |
| 3961 | 4098 | ||
| @@ -4313,7 +4450,7 @@ During a selection process, these are the local bindings. | |||
| 4313 | ;;;###autoload | 4450 | ;;;###autoload |
| 4314 | (defun reftex-citation (&optional no-insert) | 4451 | (defun reftex-citation (&optional no-insert) |
| 4315 | "Make a citation using BibTeX database files. | 4452 | "Make a citation using BibTeX database files. |
| 4316 | After asking for a Regular Expression, it scans the buffers with | 4453 | After prompting for a regular expression, scans the buffers with |
| 4317 | bibtex entries (taken from the \\bibliography command) and offers the | 4454 | bibtex entries (taken from the \\bibliography command) and offers the |
| 4318 | matching entries for selection. The selected entry is formated according | 4455 | matching entries for selection. The selected entry is formated according |
| 4319 | to `reftex-cite-format' and inserted into the buffer. | 4456 | to `reftex-cite-format' and inserted into the buffer. |
| @@ -4539,6 +4676,7 @@ bibliography statement (e.g. if it was changed)." | |||
| 4539 | (reftex-insert-bib-matches found-list)) | 4676 | (reftex-insert-bib-matches found-list)) |
| 4540 | (goto-char 1)) | 4677 | (goto-char 1)) |
| 4541 | ((eq key ?A) | 4678 | ((eq key ?A) |
| 4679 | (debug) | ||
| 4542 | ;; Take all | 4680 | ;; Take all |
| 4543 | (setq selected-entries found-list) | 4681 | (setq selected-entries found-list) |
| 4544 | (throw 'done t)) | 4682 | (throw 'done t)) |
| @@ -4745,7 +4883,7 @@ bibliography statement (e.g. if it was changed)." | |||
| 4745 | ;; of the element. | 4883 | ;; of the element. |
| 4746 | ;; CB-FLAG is the initial value of that flag. | 4884 | ;; CB-FLAG is the initial value of that flag. |
| 4747 | 4885 | ||
| 4748 | (let* (ev data last-data callback-fwd (selection-buffer (current-buffer))) | 4886 | (let* (ev data last-data (selection-buffer (current-buffer))) |
| 4749 | 4887 | ||
| 4750 | (setq ev | 4888 | (setq ev |
| 4751 | (catch 'myexit | 4889 | (catch 'myexit |
| @@ -4753,23 +4891,8 @@ bibliography statement (e.g. if it was changed)." | |||
| 4753 | (setq truncate-lines t) | 4891 | (setq truncate-lines t) |
| 4754 | 4892 | ||
| 4755 | ;; Find a good starting point | 4893 | ;; Find a good starting point |
| 4756 | (cond | 4894 | (reftex-find-start-point |
| 4757 | (offset | 4895 | (point-min) offset reftex-last-data reftex-last-line) |
| 4758 | (goto-char | ||
| 4759 | (or (and (listp offset) | ||
| 4760 | (text-property-any (point-min) (point-max) | ||
| 4761 | ':data offset)) | ||
| 4762 | (and (local-variable-p 'reftex-last-data (current-buffer)) | ||
| 4763 | (boundp 'reftex-last-data) | ||
| 4764 | (listp reftex-last-data) | ||
| 4765 | (text-property-any (point-min) (point-max) | ||
| 4766 | ':data reftex-last-data)) | ||
| 4767 | (and (local-variable-p 'reftex-last-line (current-buffer)) | ||
| 4768 | (boundp 'reftex-last-line) | ||
| 4769 | (integerp reftex-last-line) | ||
| 4770 | (progn (goto-line reftex-last-line) (point))) | ||
| 4771 | (point-min)))) | ||
| 4772 | (t (goto-char (point-min)))) | ||
| 4773 | (beginning-of-line 1) | 4896 | (beginning-of-line 1) |
| 4774 | (set (make-local-variable 'reftex-last-follow-point) (point)) | 4897 | (set (make-local-variable 'reftex-last-follow-point) (point)) |
| 4775 | 4898 | ||
| @@ -4796,7 +4919,7 @@ bibliography statement (e.g. if it was changed)." | |||
| 4796 | (+ (count-lines (point-min) (point)) (if (bolp) 1 0))) | 4919 | (+ (count-lines (point-min) (point)) (if (bolp) 1 0))) |
| 4797 | (set (make-local-variable 'reftex-last-data) last-data) | 4920 | (set (make-local-variable 'reftex-last-data) last-data) |
| 4798 | (reftex-kill-buffer "*RefTeX Help*") | 4921 | (reftex-kill-buffer "*RefTeX Help*") |
| 4799 | (setq callback-fwd (not callback-fwd)) ;; ;-))) | 4922 | (setq reftex-callback-fwd (not reftex-callback-fwd)) ;; ;-))) |
| 4800 | (message "") | 4923 | (message "") |
| 4801 | (list ev data last-data))) | 4924 | (list ev data last-data))) |
| 4802 | 4925 | ||
| @@ -4810,7 +4933,6 @@ bibliography statement (e.g. if it was changed)." | |||
| 4810 | (defvar last-data) | 4933 | (defvar last-data) |
| 4811 | (defvar call-back) | 4934 | (defvar call-back) |
| 4812 | (defvar help-string) | 4935 | (defvar help-string) |
| 4813 | (defvar callback-fwd) | ||
| 4814 | (defvar varioref) | 4936 | (defvar varioref) |
| 4815 | 4937 | ||
| 4816 | ;; The selection commands | 4938 | ;; The selection commands |
| @@ -4827,7 +4949,7 @@ bibliography statement (e.g. if it was changed)." | |||
| 4827 | (when (and data cb-flag | 4949 | (when (and data cb-flag |
| 4828 | (not (equal reftex-last-follow-point (point)))) | 4950 | (not (equal reftex-last-follow-point (point)))) |
| 4829 | (setq reftex-last-follow-point (point)) | 4951 | (setq reftex-last-follow-point (point)) |
| 4830 | (funcall call-back data callback-fwd | 4952 | (funcall call-back data reftex-callback-fwd |
| 4831 | (not reftex-revisit-to-follow))) | 4953 | (not reftex-revisit-to-follow))) |
| 4832 | (if data | 4954 | (if data |
| 4833 | (setq b (or (previous-single-property-change | 4955 | (setq b (or (previous-single-property-change |
| @@ -4848,14 +4970,14 @@ bibliography statement (e.g. if it was changed)." | |||
| 4848 | (defun reftex-select-next (&optional arg) | 4970 | (defun reftex-select-next (&optional arg) |
| 4849 | "Move to next selectable item." | 4971 | "Move to next selectable item." |
| 4850 | (interactive "p") | 4972 | (interactive "p") |
| 4851 | (setq callback-fwd t) | 4973 | (setq reftex-callback-fwd t) |
| 4852 | (or (eobp) (forward-char 1)) | 4974 | (or (eobp) (forward-char 1)) |
| 4853 | (re-search-forward "^[^. \t\n\r]" nil t arg) | 4975 | (re-search-forward "^[^. \t\n\r]" nil t arg) |
| 4854 | (beginning-of-line 1)) | 4976 | (beginning-of-line 1)) |
| 4855 | (defun reftex-select-previous (&optional arg) | 4977 | (defun reftex-select-previous (&optional arg) |
| 4856 | "Move to previous selectable item." | 4978 | "Move to previous selectable item." |
| 4857 | (interactive "p") | 4979 | (interactive "p") |
| 4858 | (setq callback-fwd nil) | 4980 | (setq reftex-callback-fwd nil) |
| 4859 | (re-search-backward "^[^. \t\n\r]" nil t arg)) | 4981 | (re-search-backward "^[^. \t\n\r]" nil t arg)) |
| 4860 | (defun reftex-select-next-heading (&optional arg) | 4982 | (defun reftex-select-next-heading (&optional arg) |
| 4861 | "Move to next table of contentes line." | 4983 | "Move to next table of contentes line." |
| @@ -4915,7 +5037,7 @@ bibliography statement (e.g. if it was changed)." | |||
| 4915 | (defun reftex-select-callback () | 5037 | (defun reftex-select-callback () |
| 4916 | "Show full context in another window." | 5038 | "Show full context in another window." |
| 4917 | (interactive) | 5039 | (interactive) |
| 4918 | (if data (funcall call-back data callback-fwd nil) (ding))) | 5040 | (if data (funcall call-back data reftex-callback-fwd nil) (ding))) |
| 4919 | (defun reftex-select-accept () | 5041 | (defun reftex-select-accept () |
| 4920 | "Accept the currently selected item." | 5042 | "Accept the currently selected item." |
| 4921 | (interactive) | 5043 | (interactive) |
| @@ -5074,7 +5196,7 @@ arrange for its removal before the next command." | |||
| 5074 | (xr-re (nth 2 xr-data)) | 5196 | (xr-re (nth 2 xr-data)) |
| 5075 | (entry (assoc label (symbol-value reftex-docstruct-symbol))) | 5197 | (entry (assoc label (symbol-value reftex-docstruct-symbol))) |
| 5076 | (win (selected-window)) pop-win (pos (point))) | 5198 | (win (selected-window)) pop-win (pos (point))) |
| 5077 | 5199 | ||
| 5078 | (if (and (not entry) (stringp label) xr-re (string-match xr-re label)) | 5200 | (if (and (not entry) (stringp label) xr-re (string-match xr-re label)) |
| 5079 | ;; Label is defined in external document | 5201 | ;; Label is defined in external document |
| 5080 | (save-excursion | 5202 | (save-excursion |
| @@ -5089,11 +5211,14 @@ arrange for its removal before the next command." | |||
| 5089 | (setq entry | 5211 | (setq entry |
| 5090 | (assoc label (symbol-value reftex-docstruct-symbol))))) | 5212 | (assoc label (symbol-value reftex-docstruct-symbol))))) |
| 5091 | (if (eq how 'echo) | 5213 | (if (eq how 'echo) |
| 5214 | ;; Dsiplay in echo area | ||
| 5092 | (reftex-echo-ref label entry (symbol-value reftex-docstruct-symbol)) | 5215 | (reftex-echo-ref label entry (symbol-value reftex-docstruct-symbol)) |
| 5093 | (unless entry | 5216 | (let ((window-conf (current-window-configuration))) |
| 5094 | (message "Label %s not known - reparse document might help" label)) | 5217 | (condition-case nil |
| 5095 | 5218 | (reftex-show-label-location entry t nil t t) | |
| 5096 | (reftex-pop-to-label label (list (nth 3 entry)) nil t) | 5219 | (error (set-window-configuration window-conf) |
| 5220 | (message "ref: Label %s not found" label) | ||
| 5221 | (error "ref: Label %s not found" label)))) ;; 2nd is line OK | ||
| 5097 | (add-hook 'pre-command-hook 'reftex-highlight-shall-die) | 5222 | (add-hook 'pre-command-hook 'reftex-highlight-shall-die) |
| 5098 | 5223 | ||
| 5099 | (when (eq how 'tmp-window) | 5224 | (when (eq how 'tmp-window) |
| @@ -5125,16 +5250,17 @@ With argument, actually select the window showing the cross reference." | |||
| 5125 | ;; This function was desigend to work with an idle timer. | 5250 | ;; This function was desigend to work with an idle timer. |
| 5126 | ;; We try to get out of here as quickly as possible if the call is useless. | 5251 | ;; We try to get out of here as quickly as possible if the call is useless. |
| 5127 | (and reftex-mode | 5252 | (and reftex-mode |
| 5128 | ;; Quick precheck if this might be a relevant spot | ||
| 5129 | ;; FIXME: failes with backslash in comment | ||
| 5130 | (save-excursion | ||
| 5131 | (search-backward "\\" nil t) | ||
| 5132 | (looking-at "\\\\[a-zA-Z]*\\(cite\\|ref\\)")) | ||
| 5133 | ;; Make sure message area is free if we need it. | 5253 | ;; Make sure message area is free if we need it. |
| 5134 | (or (eq reftex-auto-view-crossref 'window) (not (current-message))) | 5254 | (or (eq reftex-auto-view-crossref 'window) (not (current-message))) |
| 5135 | ;; Make sure we are not already displaying this one | 5255 | ;; Make sure we are not already displaying this one |
| 5136 | (not (memq last-command '(reftex-view-crossref | 5256 | (not (memq last-command '(reftex-view-crossref |
| 5137 | reftex-mouse-view-crossref))) | 5257 | reftex-mouse-view-crossref))) |
| 5258 | ;; Quick precheck if this might be a relevant spot | ||
| 5259 | ;; FIXME: Can fail with backslash in comment | ||
| 5260 | (save-excursion | ||
| 5261 | (search-backward "\\" nil t) | ||
| 5262 | (looking-at "\\\\[a-zA-Z]*\\(cite\\|ref\\)")) | ||
| 5263 | |||
| 5138 | (condition-case nil | 5264 | (condition-case nil |
| 5139 | (let ((current-prefix-arg nil)) | 5265 | (let ((current-prefix-arg nil)) |
| 5140 | (cond | 5266 | (cond |
| @@ -5252,7 +5378,7 @@ will display info in the echo area." | |||
| 5252 | 'reftex-view-crossref-when-idle | 5378 | 'reftex-view-crossref-when-idle |
| 5253 | reftex-idle-time reftex-idle-time t) | 5379 | reftex-idle-time reftex-idle-time t) |
| 5254 | (add-hook 'post-command-hook 'reftex-start-itimer-once) | 5380 | (add-hook 'post-command-hook 'reftex-start-itimer-once) |
| 5255 | nil) | 5381 | t) |
| 5256 | (run-with-idle-timer | 5382 | (run-with-idle-timer |
| 5257 | reftex-idle-time t 'reftex-view-crossref-when-idle))) | 5383 | reftex-idle-time t 'reftex-view-crossref-when-idle))) |
| 5258 | (unless reftex-auto-view-crossref | 5384 | (unless reftex-auto-view-crossref |
| @@ -5374,61 +5500,51 @@ will display info in the echo area." | |||
| 5374 | ;;; | 5500 | ;;; |
| 5375 | ;;; Finding files | 5501 | ;;; Finding files |
| 5376 | 5502 | ||
| 5377 | (defun reftex-find-tex-file (file master-dir &optional die) | 5503 | (defun reftex-locate-file (file type master-dir &optional die) |
| 5378 | ;; Find FILE in MASTER-DIR or on reftex-tex-path. | 5504 | "Find FILE of type TYPE in MASTER-DIR or on the path associcted with TYPE. |
| 5379 | ;; FILE may be given with or without the .tex extension. | 5505 | If the file does not have any of the legal extensions for TYPE, |
| 5380 | (let ((rec-values (if reftex-search-unrecursed-path-first '(nil t) '(t))) | 5506 | try first the default extension and only then the naked file name. |
| 5381 | path file1 old-path) | 5507 | When DIE is non-nil, throw an error if file not found." |
| 5508 | (let* ((rec-values (if reftex-search-unrecursed-path-first '(nil t) '(t))) | ||
| 5509 | (extensions (cdr (assoc type reftex-file-extensions))) | ||
| 5510 | (def-ext (car extensions)) | ||
| 5511 | (ext-re (concat "\\(" | ||
| 5512 | (mapconcat 'regexp-quote extensions "\\|") | ||
| 5513 | "\\)\\'")) | ||
| 5514 | (files (if (string-match ext-re file) | ||
| 5515 | (cons file nil) | ||
| 5516 | (cons (concat file def-ext) file))) | ||
| 5517 | path old-path file1) | ||
| 5382 | (cond | 5518 | (cond |
| 5383 | ((file-name-absolute-p file) | 5519 | ((file-name-absolute-p file) |
| 5384 | (if (file-regular-p (concat file ".tex")) | 5520 | (setq file1 |
| 5385 | (setq file1 (concat file ".tex")) | 5521 | (or |
| 5386 | (if (file-regular-p file) (setq file1 file)))) | 5522 | (and (car files) (file-regular-p (car files)) (car files)) |
| 5523 | (and (cdr files) (file-regular-p (cdr files)) (cdr files))))) | ||
| 5387 | ((and reftex-use-external-file-finders | 5524 | ((and reftex-use-external-file-finders |
| 5388 | (assoc "tex" reftex-external-file-finders)) | 5525 | (assoc type reftex-external-file-finders)) |
| 5389 | (setq file1 (reftex-find-file-externally file "tex" master-dir))) | 5526 | (setq file1 (reftex-find-file-externally file type master-dir))) |
| 5390 | (t | 5527 | (t |
| 5391 | (while (and (null file1) rec-values) | 5528 | (while (and (null file1) rec-values) |
| 5392 | (setq path (reftex-access-search-path | 5529 | (setq path (reftex-access-search-path |
| 5393 | "tex" (pop rec-values) master-dir file)) | 5530 | type (pop rec-values) master-dir file)) |
| 5394 | (if (or (null old-path) | 5531 | (if (or (null old-path) |
| 5395 | (not (eq old-path path))) | 5532 | (not (eq old-path path))) |
| 5396 | (setq old-path path | 5533 | (setq old-path path |
| 5397 | path (cons master-dir path) | 5534 | path (cons master-dir path) |
| 5398 | file1 (or (reftex-find-file-on-path | 5535 | file1 (or (and (car files) |
| 5399 | (concat file ".tex") path master-dir) | 5536 | (reftex-find-file-on-path |
| 5400 | (reftex-find-file-on-path file path master-dir))))))) | 5537 | (car files) path master-dir)) |
| 5401 | (cond (file1 file1) | 5538 | (and (cdr files) |
| 5402 | (die (error "No such file: %s" file) nil) | 5539 | (reftex-find-file-on-path |
| 5403 | (t (message "No such file: %s (ignored)" file) nil)))) | 5540 | (cdr files) path master-dir)))))))) |
| 5404 | |||
| 5405 | (defun reftex-find-bib-file (file master-dir &optional die) | ||
| 5406 | ;; Find FILE in MASTER-DIR or on reftex-bib-path. | ||
| 5407 | ;; File must be given already with the .bib extension. | ||
| 5408 | (let ((rec-values (if reftex-search-unrecursed-path-first '(nil t) '(t))) | ||
| 5409 | path file1 old-path) | ||
| 5410 | (cond | ||
| 5411 | ((file-name-absolute-p file) | ||
| 5412 | (if (file-regular-p file) (setq file1 file))) | ||
| 5413 | ((and reftex-use-external-file-finders | ||
| 5414 | (assoc "bib" reftex-external-file-finders)) | ||
| 5415 | (setq file1 (reftex-find-file-externally file "bib" master-dir))) | ||
| 5416 | (t | ||
| 5417 | (while (and (null file1) rec-values) | ||
| 5418 | (setq path (reftex-access-search-path | ||
| 5419 | "bib" (pop rec-values) master-dir file)) | ||
| 5420 | (if (or (null old-path) | ||
| 5421 | (not (eq old-path path))) | ||
| 5422 | (setq old-path path | ||
| 5423 | path (cons master-dir path) | ||
| 5424 | file1 (reftex-find-file-on-path file path master-dir)))))) | ||
| 5425 | (cond (file1 file1) | 5541 | (cond (file1 file1) |
| 5426 | (die (error "No such file: %s" file) nil) | 5542 | (die (error "No such file: %s" file) nil) |
| 5427 | (t (message "No such file: %s (ignored)" file) nil)))) | 5543 | (t (message "No such file: %s (ignored)" file) nil)))) |
| 5428 | 5544 | ||
| 5429 | (defun reftex-find-file-externally (file type &optional master-dir) | 5545 | (defun reftex-find-file-externally (file type &optional master-dir) |
| 5430 | ;; Use external program to find FILE. | 5546 | ;; Use external program to find FILE. |
| 5431 | ;; The program is the association of TYPE in `reftex-external-file-finders'. | 5547 | ;; The program is taken from `reftex-external-file-finders'. |
| 5432 | ;; Interprete relative path definitions starting from MASTER-DIR. | 5548 | ;; Interprete relative path definitions starting from MASTER-DIR. |
| 5433 | (let ((default-directory (or master-dir default-directory)) | 5549 | (let ((default-directory (or master-dir default-directory)) |
| 5434 | (prg (cdr (assoc type reftex-external-file-finders))) | 5550 | (prg (cdr (assoc type reftex-external-file-finders))) |
| @@ -5445,33 +5561,36 @@ will display info in the echo area." | |||
| 5445 | (defun reftex-process-string (program &rest args) | 5561 | (defun reftex-process-string (program &rest args) |
| 5446 | "Execute PROGRAM with arguments ARGS and return its STDOUT as a string." | 5562 | "Execute PROGRAM with arguments ARGS and return its STDOUT as a string." |
| 5447 | (with-output-to-string | 5563 | (with-output-to-string |
| 5448 | (with-current-buffer | 5564 | (with-current-buffer standard-output |
| 5449 | standard-output | ||
| 5450 | (apply 'call-process program nil '(t nil) nil args)))) | 5565 | (apply 'call-process program nil '(t nil) nil args)))) |
| 5451 | 5566 | ||
| 5452 | (defun reftex-access-search-path (which &optional recurse master-dir file) | 5567 | (defun reftex-access-search-path (type &optional recurse master-dir file) |
| 5453 | ;; Access path from environment variables. WHICH is either "tex" or "bib". | 5568 | ;; Access path from environment variables. TYPE is either "tex" or "bib". |
| 5454 | ;; When RECURSE is t, expand path elements ending in `//' recursively. | 5569 | ;; When RECURSE is t, expand path elements ending in `//' recursively. |
| 5455 | ;; Relative path elements are left as they are. However, relative recursive | 5570 | ;; Relative path elements are left as they are. However, relative recursive |
| 5456 | ;; elements are expanded with MASTER-DIR as default directory. | 5571 | ;; elements are expanded with MASTER-DIR as default directory. |
| 5457 | ;; The expanded path is cached for the next search. | 5572 | ;; The expanded path is cached for the next search. |
| 5458 | ;; FILE is just for the progress message. | 5573 | ;; FILE is just for the progress message. |
| 5459 | ;; Returns the derived path. | 5574 | ;; Returns the derived path. |
| 5460 | (let* ((pathvar (intern (concat "reftex-" which "-path")))) | 5575 | (let* ((pathvar (intern (concat "reftex-" type "-path")))) |
| 5461 | (when (null (get pathvar 'status)) | 5576 | (when (null (get pathvar 'status)) |
| 5462 | ;; Get basic path from environment | 5577 | ;; Get basic path |
| 5463 | (let ((env-vars (if (equal which "tex") | 5578 | (set pathvar |
| 5464 | reftex-texpath-environment-variables | 5579 | (reftex-uniq |
| 5465 | reftex-bibpath-environment-variables))) | 5580 | (reftex-parse-colon-path |
| 5466 | (set pathvar | 5581 | (mapconcat |
| 5467 | (reftex-parse-colon-path | 5582 | (lambda(x) |
| 5468 | (mapconcat | 5583 | (if (string-match "^!" x) |
| 5469 | (lambda(x) | 5584 | (apply 'reftex-process-string |
| 5470 | (if (string-match "^!" x) | 5585 | (split-string (substring x 1))) |
| 5471 | (apply 'reftex-process-string | 5586 | (or (getenv x) x))) |
| 5472 | (split-string (substring x 1))) | 5587 | ;; For consistency, the next line should look like this: |
| 5473 | (or (getenv x) x))) | 5588 | ;; (cdr (assoc type reftex-path-environment)) |
| 5474 | env-vars path-separator)))) | 5589 | ;; However, historically we have separate options for the |
| 5590 | ;; environment variables, so we have to do this: | ||
| 5591 | (symbol-value (intern (concat "reftex-" type | ||
| 5592 | "path-environment-variables"))) | ||
| 5593 | path-separator)))) | ||
| 5475 | (put pathvar 'status 'split) | 5594 | (put pathvar 'status 'split) |
| 5476 | ;; Check if we have recursive elements | 5595 | ;; Check if we have recursive elements |
| 5477 | (let ((path (symbol-value pathvar)) dir rec) | 5596 | (let ((path (symbol-value pathvar)) dir rec) |
| @@ -5494,7 +5613,7 @@ will display info in the echo area." | |||
| 5494 | ;; Either: We don't have a recursive expansion yet. | 5613 | ;; Either: We don't have a recursive expansion yet. |
| 5495 | ;; or: Relative recursive path elements need to be expanded | 5614 | ;; or: Relative recursive path elements need to be expanded |
| 5496 | ;; relative to new default directory | 5615 | ;; relative to new default directory |
| 5497 | (message "Expanding search path to find %s file: %s ..." which file) | 5616 | (message "Expanding search path to find %s file: %s ..." type file) |
| 5498 | (put pathvar 'recursive-path | 5617 | (put pathvar 'recursive-path |
| 5499 | (reftex-expand-path (symbol-value pathvar) master-dir)) | 5618 | (reftex-expand-path (symbol-value pathvar) master-dir)) |
| 5500 | (put pathvar 'master-dir master-dir) | 5619 | (put pathvar 'master-dir master-dir) |
| @@ -5513,7 +5632,7 @@ will display info in the echo area." | |||
| 5513 | (if (file-regular-p file) | 5632 | (if (file-regular-p file) |
| 5514 | (throw 'exit file) | 5633 | (throw 'exit file) |
| 5515 | (throw 'exit nil))) | 5634 | (throw 'exit nil))) |
| 5516 | (let* ((thepath path) file1 dir ) | 5635 | (let* ((thepath path) file1 dir) |
| 5517 | (while (setq dir (pop thepath)) | 5636 | (while (setq dir (pop thepath)) |
| 5518 | (when (string= (substring dir -2) "//") | 5637 | (when (string= (substring dir -2) "//") |
| 5519 | (setq dir (substring dir 0 -1))) | 5638 | (setq dir (substring dir 0 -1))) |
| @@ -5562,6 +5681,14 @@ will display info in the echo area." | |||
| 5562 | (push dir path1))) | 5681 | (push dir path1))) |
| 5563 | path1)) | 5682 | path1)) |
| 5564 | 5683 | ||
| 5684 | (defun reftex-uniq (list) | ||
| 5685 | (let (new) | ||
| 5686 | (while list | ||
| 5687 | (or (member (car list) new) | ||
| 5688 | (push (car list) new)) | ||
| 5689 | (pop list)) | ||
| 5690 | (nreverse new))) | ||
| 5691 | |||
| 5565 | ;;; ========================================================================= | 5692 | ;;; ========================================================================= |
| 5566 | ;;; | 5693 | ;;; |
| 5567 | ;;; Some generally useful functions | 5694 | ;;; Some generally useful functions |
| @@ -5634,29 +5761,17 @@ will display info in the echo area." | |||
| 5634 | list (cdr list))) | 5761 | list (cdr list))) |
| 5635 | last-ass)) | 5762 | last-ass)) |
| 5636 | 5763 | ||
| 5637 | (defvar enable-multibyte-characters) | ||
| 5638 | (defun reftex-truncate (string ncols &optional ellipses padding) | 5764 | (defun reftex-truncate (string ncols &optional ellipses padding) |
| 5639 | ;; Truncate a string to NCHAR characters. | 5765 | ;; Truncate STRING to NCOLS characters. |
| 5640 | ;; Works fast with ASCII and correctly with Mule characters. | 5766 | ;; When PADDING is non-nil, and string is shorter than NCOLS, fill with |
| 5641 | ;; When ELLIPSES is non-nil, put three dots at the end of the string. | 5767 | ;; white space to NCOLS characters. When ELLIPSES is non-nil and the |
| 5642 | ;; When padding is non-nil, fills with white space to NCOLS characters. | 5768 | ;; string needs to be truncated, replace last 3 characters by dots. |
| 5643 | (setq string | 5769 | (setq string |
| 5644 | (cond | 5770 | (if (<= (length string) ncols) |
| 5645 | ((and (boundp 'enable-multibyte-characters) | 5771 | string |
| 5646 | enable-multibyte-characters | 5772 | (if ellipses |
| 5647 | (fboundp 'string-width) | 5773 | (concat (substring string 0 (- ncols 3)) "...") |
| 5648 | (fboundp 'truncate-string-to-width)) | 5774 | (substring string 0 ncols)))) |
| 5649 | (if (<= (string-width string) ncols) | ||
| 5650 | string | ||
| 5651 | (if ellipses | ||
| 5652 | (concat (truncate-string-to-width string (- ncols 3)) "...") | ||
| 5653 | (truncate-string-to-width string ncols)))) | ||
| 5654 | (t | ||
| 5655 | (if (<= (length string) ncols) | ||
| 5656 | string | ||
| 5657 | (if ellipses | ||
| 5658 | (concat (substring string 0 (- ncols 3)) "...") | ||
| 5659 | (substring string 0 ncols)))))) | ||
| 5660 | (if padding | 5775 | (if padding |
| 5661 | (format (format "%%-%ds" ncols) string) | 5776 | (format (format "%%-%ds" ncols) string) |
| 5662 | string)) | 5777 | string)) |
| @@ -5906,7 +6021,7 @@ will display info in the echo area." | |||
| 5906 | (font-lock-mode 1))) | 6021 | (font-lock-mode 1))) |
| 5907 | ((fboundp 'font-lock-set-defaults-1) | 6022 | ((fboundp 'font-lock-set-defaults-1) |
| 5908 | ;; Looks like the XEmacs font-lock stuff. | 6023 | ;; Looks like the XEmacs font-lock stuff. |
| 5909 | ;; FIXME: this is still kind of a hack. | 6024 | ;; FIXME: this is still kind of a hack, but it works. |
| 5910 | (set (make-local-variable 'font-lock-keywords) nil) | 6025 | (set (make-local-variable 'font-lock-keywords) nil) |
| 5911 | (let ((major-mode 'latex-mode) | 6026 | (let ((major-mode 'latex-mode) |
| 5912 | (font-lock-defaults-computed nil)) | 6027 | (font-lock-defaults-computed nil)) |
| @@ -6324,7 +6439,7 @@ No active TAGS table is required." | |||
| 6324 | (grep cmd))) | 6439 | (grep cmd))) |
| 6325 | 6440 | ||
| 6326 | (defun reftex-search-document (&optional regexp) | 6441 | (defun reftex-search-document (&optional regexp) |
| 6327 | "Regexp search through all files of the current TeX document. | 6442 | "Regexp search through all files of the current document. |
| 6328 | Starts always in the master file. Stops when a match is found. | 6443 | Starts always in the master file. Stops when a match is found. |
| 6329 | To continue searching for next match, use command \\[tags-loop-continue]. | 6444 | To continue searching for next match, use command \\[tags-loop-continue]. |
| 6330 | No active TAGS table is required." | 6445 | No active TAGS table is required." |
| @@ -6339,7 +6454,7 @@ No active TAGS table is required." | |||
| 6339 | (tags-search regexp (list 'reftex-all-document-files)))) | 6454 | (tags-search regexp (list 'reftex-all-document-files)))) |
| 6340 | 6455 | ||
| 6341 | (defun reftex-query-replace-document (&optional from to delimited) | 6456 | (defun reftex-query-replace-document (&optional from to delimited) |
| 6342 | "Run a query-replace-regexp of FROM with TO over the entire TeX document. | 6457 | "Run a query-replace-regexp of FROM with TO over the entire document. |
| 6343 | Third arg DELIMITED (prefix arg) means replace only word-delimited matches. | 6458 | Third arg DELIMITED (prefix arg) means replace only word-delimited matches. |
| 6344 | If you exit (\\[keyboard-quit] or ESC), you can resume the query replace | 6459 | If you exit (\\[keyboard-quit] or ESC), you can resume the query replace |
| 6345 | with the command \\[tags-loop-continue]. | 6460 | with the command \\[tags-loop-continue]. |
| @@ -6392,8 +6507,7 @@ No active TAGS table is required." | |||
| 6392 | (setq dlist (reftex-uniquify-by-car dlist)) | 6507 | (setq dlist (reftex-uniquify-by-car dlist)) |
| 6393 | (if (null dlist) (error "No duplicate labels in document")) | 6508 | (if (null dlist) (error "No duplicate labels in document")) |
| 6394 | (switch-to-buffer-other-window "*Duplicate Labels*") | 6509 | (switch-to-buffer-other-window "*Duplicate Labels*") |
| 6395 | (make-local-variable 'TeX-master) | 6510 | (set (make-local-variable 'TeX-master) master) |
| 6396 | (setq TeX-master master) | ||
| 6397 | (erase-buffer) | 6511 | (erase-buffer) |
| 6398 | (insert " MULTIPLE LABELS IN CURRENT DOCUMENT:\n") | 6512 | (insert " MULTIPLE LABELS IN CURRENT DOCUMENT:\n") |
| 6399 | (insert | 6513 | (insert |
| @@ -6884,9 +6998,14 @@ for possible values. This function should be used from AUCTeX style files." | |||
| 6884 | (define-key reftex-toc-map [(button2)] 'reftex-toc-mouse-goto-line-and-hide) | 6998 | (define-key reftex-toc-map [(button2)] 'reftex-toc-mouse-goto-line-and-hide) |
| 6885 | (define-key reftex-toc-map [(mouse-2)] 'reftex-toc-mouse-goto-line-and-hide)) | 6999 | (define-key reftex-toc-map [(mouse-2)] 'reftex-toc-mouse-goto-line-and-hide)) |
| 6886 | 7000 | ||
| 7001 | (substitute-key-definition | ||
| 7002 | 'next-line 'reftex-toc-next reftex-toc-map global-map) | ||
| 7003 | (substitute-key-definition | ||
| 7004 | 'previous-line 'reftex-toc-previous reftex-toc-map global-map) | ||
| 7005 | |||
| 6887 | (loop for x in | 7006 | (loop for x in |
| 6888 | '(("n" . next-line) | 7007 | '(("n" . reftex-toc-next) |
| 6889 | ("p" . previous-line) | 7008 | ("p" . reftex-toc-previous) |
| 6890 | ("?" . reftex-toc-show-help) | 7009 | ("?" . reftex-toc-show-help) |
| 6891 | (" " . reftex-toc-view-line) | 7010 | (" " . reftex-toc-view-line) |
| 6892 | ("\C-m" . reftex-toc-goto-line-and-hide) | 7011 | ("\C-m" . reftex-toc-goto-line-and-hide) |
| @@ -6897,8 +7016,12 @@ for possible values. This function should be used from AUCTeX style files." | |||
| 6897 | ("q" . reftex-toc-quit) | 7016 | ("q" . reftex-toc-quit) |
| 6898 | ("Q" . reftex-toc-quit-and-kill) | 7017 | ("Q" . reftex-toc-quit-and-kill) |
| 6899 | ("f" . reftex-toc-toggle-follow) | 7018 | ("f" . reftex-toc-toggle-follow) |
| 7019 | ("i" . reftex-toc-toggle-file-boundary) | ||
| 7020 | ("l" . reftex-toc-toggle-labels) | ||
| 7021 | ("c" . reftex-toc-toggle-context) | ||
| 7022 | ("%" . reftex-toc-toggle-commented) | ||
| 6900 | ("x" . reftex-toc-external) | 7023 | ("x" . reftex-toc-external) |
| 6901 | ("." . reftex-toc-show-insertion-point)) | 7024 | ("." . reftex-toc-show-calling-point)) |
| 6902 | do (define-key reftex-toc-map (car x) (cdr x))) | 7025 | do (define-key reftex-toc-map (car x) (cdr x))) |
| 6903 | 7026 | ||
| 6904 | (loop for key across "0123456789" do | 7027 | (loop for key across "0123456789" do |
| @@ -6913,8 +7036,7 @@ for possible values. This function should be used from AUCTeX style files." | |||
| 6913 | 7036 | ||
| 6914 | (require 'easymenu) | 7037 | (require 'easymenu) |
| 6915 | 7038 | ||
| 6916 | (easy-menu-define | 7039 | (easy-menu-define reftex-mode-menu reftex-mode-map |
| 6917 | reftex-mode-menu reftex-mode-map | ||
| 6918 | "Menu used in RefTeX mode" | 7040 | "Menu used in RefTeX mode" |
| 6919 | `("Ref" | 7041 | `("Ref" |
| 6920 | ["Table of Contents" reftex-toc t] | 7042 | ["Table of Contents" reftex-toc t] |
| @@ -6943,13 +7065,16 @@ for possible values. This function should be used from AUCTeX style files." | |||
| 6943 | ["Change Label and Refs" reftex-change-label t] | 7065 | ["Change Label and Refs" reftex-change-label t] |
| 6944 | ["Renumber Simple Labels" reftex-renumber-simple-labels t] | 7066 | ["Renumber Simple Labels" reftex-renumber-simple-labels t] |
| 6945 | "---" | 7067 | "---" |
| 6946 | ["Save document" reftex-save-all-document-buffers t]) | 7068 | ["Save Document" reftex-save-all-document-buffers t]) |
| 6947 | "---" | 7069 | "---" |
| 6948 | ("Options" | 7070 | ("Options" |
| 6949 | ("Table of Contents" | 7071 | ("Table of Contents" |
| 7072 | ["Keep Other Windows" (setq reftex-toc-keep-other-windows | ||
| 7073 | (not reftex-toc-keep-other-windows)) | ||
| 7074 | :style toggle :selected reftex-toc-keep-other-windows] | ||
| 6950 | ["Follow Mode" (setq reftex-toc-follow-mode (not reftex-toc-follow-mode)) | 7075 | ["Follow Mode" (setq reftex-toc-follow-mode (not reftex-toc-follow-mode)) |
| 6951 | :style toggle :selected reftex-toc-follow-mode] | 7076 | :style toggle :selected reftex-toc-follow-mode] |
| 6952 | ["Follow Mode may visit files" | 7077 | ["Follow Mode may Visit Files" |
| 6953 | (setq reftex-revisit-to-follow (not reftex-revisit-to-follow)) | 7078 | (setq reftex-revisit-to-follow (not reftex-revisit-to-follow)) |
| 6954 | :style toggle :selected reftex-revisit-to-follow]) | 7079 | :style toggle :selected reftex-revisit-to-follow]) |
| 6955 | ("References" | 7080 | ("References" |
| @@ -6987,14 +7112,14 @@ for possible values. This function should be used from AUCTeX style files." | |||
| 6987 | :style toggle :selected reftex-comment-citations] | 7112 | :style toggle :selected reftex-comment-citations] |
| 6988 | "---" | 7113 | "---" |
| 6989 | "Sort Database Matches" | 7114 | "Sort Database Matches" |
| 7115 | ["Not" (setq reftex-sort-bibtex-matches nil) | ||
| 7116 | :style radio :selected (eq reftex-sort-bibtex-matches nil)] | ||
| 6990 | ["by Author" (setq reftex-sort-bibtex-matches 'author) | 7117 | ["by Author" (setq reftex-sort-bibtex-matches 'author) |
| 6991 | :style radio :selected (eq reftex-sort-bibtex-matches 'author)] | 7118 | :style radio :selected (eq reftex-sort-bibtex-matches 'author)] |
| 6992 | ["by Year" (setq reftex-sort-bibtex-matches 'year) | 7119 | ["by Year" (setq reftex-sort-bibtex-matches 'year) |
| 6993 | :style radio :selected (eq reftex-sort-bibtex-matches 'year)] | 7120 | :style radio :selected (eq reftex-sort-bibtex-matches 'year)] |
| 6994 | ["by Year, reversed" (setq reftex-sort-bibtex-matches 'reverse-year) | 7121 | ["by Year, reversed" (setq reftex-sort-bibtex-matches 'reverse-year) |
| 6995 | :style radio :selected (eq reftex-sort-bibtex-matches 'reverse-year)] | 7122 | :style radio :selected (eq reftex-sort-bibtex-matches 'reverse-year)]) |
| 6996 | ["Not" (setq reftex-sort-bibtex-matches nil) | ||
| 6997 | :style radio :selected (eq reftex-sort-bibtex-matches nil)]) | ||
| 6998 | ("Crossref Viewing" | 7123 | ("Crossref Viewing" |
| 6999 | ["Automatic Info" reftex-toggle-auto-view-crossref | 7124 | ["Automatic Info" reftex-toggle-auto-view-crossref |
| 7000 | :style toggle :selected reftex-auto-view-crossref-timer] | 7125 | :style toggle :selected reftex-auto-view-crossref-timer] |
| @@ -7003,10 +7128,10 @@ for possible values. This function should be used from AUCTeX style files." | |||
| 7003 | ["...in Other Window" (setq reftex-auto-view-crossref 'window) | 7128 | ["...in Other Window" (setq reftex-auto-view-crossref 'window) |
| 7004 | :style radio :selected (eq reftex-auto-view-crossref 'window)] | 7129 | :style radio :selected (eq reftex-auto-view-crossref 'window)] |
| 7005 | "---" | 7130 | "---" |
| 7006 | ["Crossref Echo may visit files" | 7131 | ["Crossref Echo may Visit Files" |
| 7007 | (setq reftex-revisit-to-echo (not reftex-revisit-to-echo)) | 7132 | (setq reftex-revisit-to-echo (not reftex-revisit-to-echo)) |
| 7008 | :style toggle :selected reftex-revisit-to-echo] | 7133 | :style toggle :selected reftex-revisit-to-echo] |
| 7009 | ["Cache Echo strings for \cite" | 7134 | ["Cache Echo Strings for \cite" |
| 7010 | (setq reftex-cache-cite-echo (not reftex-cache-cite-echo)) | 7135 | (setq reftex-cache-cite-echo (not reftex-cache-cite-echo)) |
| 7011 | :style toggle :selected reftex-cache-cite-echo]) | 7136 | :style toggle :selected reftex-cache-cite-echo]) |
| 7012 | ("Parser" | 7137 | ("Parser" |
| @@ -7040,7 +7165,7 @@ for possible values. This function should be used from AUCTeX style files." | |||
| 7040 | :style toggle :selected (reftex-refontify)])) | 7165 | :style toggle :selected (reftex-refontify)])) |
| 7041 | ;;"---" | 7166 | ;;"---" |
| 7042 | ("Customize" | 7167 | ("Customize" |
| 7043 | ["Browse RefTeX group" reftex-customize t] | 7168 | ["Browse RefTeX Group" reftex-customize t] |
| 7044 | "---" | 7169 | "---" |
| 7045 | ["Build Full Customize Menu" reftex-create-customize-menu | 7170 | ["Build Full Customize Menu" reftex-create-customize-menu |
| 7046 | (fboundp 'customize-menu-create)]) | 7171 | (fboundp 'customize-menu-create)]) |
| @@ -7084,19 +7209,11 @@ for possible values. This function should be used from AUCTeX style files." | |||
| 7084 | (require 'info) | 7209 | (require 'info) |
| 7085 | (Info-goto-node "(reftex)")) | 7210 | (Info-goto-node "(reftex)")) |
| 7086 | 7211 | ||
| 7087 | ;; Support for \label and \ref -------------------------------------- | ||
| 7088 | |||
| 7089 | ;;; Install the kill-buffer and kill-emacs hooks ------------------------------ | 7212 | ;;; Install the kill-buffer and kill-emacs hooks ------------------------------ |
| 7090 | 7213 | ||
| 7091 | (add-hook 'kill-buffer-hook 'reftex-kill-buffer-hook) | 7214 | (add-hook 'kill-buffer-hook 'reftex-kill-buffer-hook) |
| 7092 | (add-hook 'kill-emacs-hook 'reftex-kill-emacs-hook) | 7215 | (add-hook 'kill-emacs-hook 'reftex-kill-emacs-hook) |
| 7093 | 7216 | ||
| 7094 | ;;; Install the idle timer if requested --------------------------------------- | ||
| 7095 | |||
| 7096 | (and reftex-auto-view-crossref | ||
| 7097 | (not reftex-auto-view-crossref-timer) | ||
| 7098 | (reftex-toggle-auto-view-crossref)) | ||
| 7099 | |||
| 7100 | ;;; Run Hook ------------------------------------------------------------------ | 7217 | ;;; Run Hook ------------------------------------------------------------------ |
| 7101 | 7218 | ||
| 7102 | (run-hooks 'reftex-load-hook) | 7219 | (run-hooks 'reftex-load-hook) |