1 |
;;; reftex.el --- minor mode for doing \label, \ref, \cite, \index in LaTeX |
;;; reftex.el --- minor mode for doing \label, \ref, \cite, \index in LaTeX |
2 |
;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. |
;; Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. |
3 |
|
|
4 |
;; Author: Carsten Dominik <dominik@strw.LeidenUniv.nl> |
;; Author: Carsten Dominik <dominik@science.uva.nl> |
5 |
;; Version: 4.16 |
;; Version: 4.18 |
6 |
;; Keywords: tex |
;; Keywords: tex |
7 |
|
|
8 |
;; This file is part of GNU Emacs. |
;; This file is part of GNU Emacs. |
25 |
;;--------------------------------------------------------------------------- |
;;--------------------------------------------------------------------------- |
26 |
;; |
;; |
27 |
;;; Commentary: |
;;; Commentary: |
28 |
;; |
;; |
29 |
;; RefTeX is a minor mode with distinct support for \ref, \label, \cite, |
;; RefTeX is a minor mode with distinct support for \ref, \label, \cite, |
30 |
;; and \index commands in (multi-file) LaTeX documents. |
;; and \index commands in (multi-file) LaTeX documents. |
31 |
;; - A table of contents provides easy access to any part of a document. |
;; - A table of contents provides easy access to any part of a document. |
70 |
;; |
;; |
71 |
;; Introduction |
;; Introduction |
72 |
;; ************ |
;; ************ |
73 |
;; |
;; |
74 |
;; RefTeX is a specialized package for support of labels, references, |
;; RefTeX is a specialized package for support of labels, references, |
75 |
;; citations, and the index in LaTeX. RefTeX wraps itself round 4 LaTeX |
;; citations, and the index in LaTeX. RefTeX wraps itself round 4 LaTeX |
76 |
;; macros: `\label', `\ref', `\cite', and `\index'. Using these macros |
;; macros: `\label', `\ref', `\cite', and `\index'. Using these macros |
79 |
;; time-consuming tasks almost entirely. It also provides functions to |
;; time-consuming tasks almost entirely. It also provides functions to |
80 |
;; display the structure of a document and to move around in this |
;; display the structure of a document and to move around in this |
81 |
;; structure quickly. |
;; structure quickly. |
82 |
;; |
;; |
83 |
;; *Note Imprint::, for information about who to contact for help, bug |
;; *Note Imprint::, for information about who to contact for help, bug |
84 |
;; reports or suggestions. |
;; reports or suggestions. |
85 |
;; |
;; |
86 |
;; Environment |
;; Environment |
87 |
;; =========== |
;; =========== |
88 |
;; |
;; |
89 |
;; RefTeX needs to access all files which are part of a multifile |
;; RefTeX needs to access all files which are part of a multifile |
90 |
;; document, and the BibTeX database files requested by the |
;; document, and the BibTeX database files requested by the |
91 |
;; `\bibliography' command. To find these files, RefTeX will require a |
;; `\bibliography' command. To find these files, RefTeX will require a |
94 |
;; which are also used by RefTeX. However, on some systems these |
;; which are also used by RefTeX. However, on some systems these |
95 |
;; variables do not contain the full search path. If RefTeX does not work |
;; variables do not contain the full search path. If RefTeX does not work |
96 |
;; for you because it cannot find some files, read *Note Finding Files::. |
;; for you because it cannot find some files, read *Note Finding Files::. |
97 |
;; |
;; |
98 |
;; Entering RefTeX Mode |
;; Entering RefTeX Mode |
99 |
;; ==================== |
;; ==================== |
100 |
;; |
;; |
101 |
;; To turn RefTeX Mode on and off in a particular buffer, use `M-x |
;; To turn RefTeX Mode on and off in a particular buffer, use `M-x |
102 |
;; reftex-mode'. To turn on RefTeX Mode for all LaTeX files, add the |
;; reftex-mode'. To turn on RefTeX Mode for all LaTeX files, add the |
103 |
;; following lines to your `.emacs' file: |
;; following lines to your `.emacs' file: |
104 |
;; |
;; |
105 |
;; (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode |
;; (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode |
106 |
;; (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode |
;; (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode |
107 |
;; |
;; |
108 |
;; RefTeX in a Nutshell |
;; RefTeX in a Nutshell |
109 |
;; ==================== |
;; ==================== |
110 |
;; |
;; |
111 |
;; 1. Table of Contents |
;; 1. Table of Contents |
112 |
;; Typing `C-c =' (`reftex-toc') will show a table of contents of the |
;; Typing `C-c =' (`reftex-toc') will show a table of contents of the |
113 |
;; document. This buffer can display sections, labels and index |
;; document. This buffer can display sections, labels and index |
114 |
;; entries defined in the document. From the buffer, you can jump |
;; entries defined in the document. From the buffer, you can jump |
115 |
;; quickly to every part of your document. Press `?' to get help. |
;; quickly to every part of your document. Press `?' to get help. |
116 |
;; |
;; |
117 |
;; 2. Labels and References |
;; 2. Labels and References |
118 |
;; RefTeX helps to create unique labels and to find the correct key |
;; RefTeX helps to create unique labels and to find the correct key |
119 |
;; for references quickly. It distinguishes labels for different |
;; for references quickly. It distinguishes labels for different |
121 |
;; others), and can be configured to recognize any additional labeled |
;; others), and can be configured to recognize any additional labeled |
122 |
;; environments you have defined yourself (variable |
;; environments you have defined yourself (variable |
123 |
;; `reftex-label-alist'). |
;; `reftex-label-alist'). |
124 |
;; |
;; |
125 |
;; * Creating Labels |
;; * Creating Labels |
126 |
;; Type `C-c (' (`reftex-label') to insert a label at point. |
;; Type `C-c (' (`reftex-label') to insert a label at point. |
127 |
;; RefTeX will either |
;; RefTeX will either |
130 |
;; tables) or |
;; tables) or |
131 |
;; - insert a simple label made of a prefix and a number (all |
;; - insert a simple label made of a prefix and a number (all |
132 |
;; other environments) |
;; other environments) |
133 |
;; |
;; |
134 |
;; Which labels are created how is configurable with the variable |
;; Which labels are created how is configurable with the variable |
135 |
;; `reftex-insert-label-flags'. |
;; `reftex-insert-label-flags'. |
136 |
;; |
;; |
137 |
;; * Referencing Labels |
;; * Referencing Labels |
138 |
;; To make a reference, type `C-c )' (`reftex-reference'). This |
;; To make a reference, type `C-c )' (`reftex-reference'). This |
139 |
;; shows an outline of the document with all labels of a certain |
;; shows an outline of the document with all labels of a certain |
140 |
;; type (figure, equation,...) and some label context. |
;; type (figure, equation,...) and some label context. |
141 |
;; Selecting a label inserts a `\ref{LABEL}' macro into the |
;; Selecting a label inserts a `\ref{LABEL}' macro into the |
142 |
;; original buffer. |
;; original buffer. |
143 |
;; |
;; |
144 |
;; 3. Citations |
;; 3. Citations |
145 |
;; Typing `C-c [' (`reftex-citation') will let you specify a regular |
;; Typing `C-c [' (`reftex-citation') will let you specify a regular |
146 |
;; expression to search in current BibTeX database files (as |
;; expression to search in current BibTeX database files (as |
149 |
;; sorted. The selected article is referenced as `\cite{KEY}' (see |
;; sorted. The selected article is referenced as `\cite{KEY}' (see |
150 |
;; the variable `reftex-cite-format' if you want to insert different |
;; the variable `reftex-cite-format' if you want to insert different |
151 |
;; macros). |
;; macros). |
152 |
;; |
;; |
153 |
;; 4. Index Support |
;; 4. Index Support |
154 |
;; RefTeX helps to enter index entries. It also compiles all entries |
;; RefTeX helps to enter index entries. It also compiles all entries |
155 |
;; into an alphabetically sorted `*Index*' buffer which you can use |
;; into an alphabetically sorted `*Index*' buffer which you can use |
157 |
;; index macros and can be configured to recognize any additional |
;; index macros and can be configured to recognize any additional |
158 |
;; macros you have defined (`reftex-index-macros'). Multiple indices |
;; macros you have defined (`reftex-index-macros'). Multiple indices |
159 |
;; are supported. |
;; are supported. |
160 |
;; |
;; |
161 |
;; * Creating Index Entries |
;; * Creating Index Entries |
162 |
;; To index the current selection or the word at point, type |
;; To index the current selection or the word at point, type |
163 |
;; `C-c /' (`reftex-index-selection-or-word'). The default macro |
;; `C-c /' (`reftex-index-selection-or-word'). The default macro |
164 |
;; `reftex-index-default-macro' will be used. For a more |
;; `reftex-index-default-macro' will be used. For a more |
165 |
;; complex entry type `C-c <' (`reftex-index'), select any of |
;; complex entry type `C-c <' (`reftex-index'), select any of |
166 |
;; the index macros and enter the arguments with completion. |
;; the index macros and enter the arguments with completion. |
167 |
;; |
;; |
168 |
;; * The Index Phrases File (Delayed Indexing) |
;; * The Index Phrases File (Delayed Indexing) |
169 |
;; Type `C-c \' (`reftex-index-phrase-selection-or-word') to add |
;; Type `C-c \' (`reftex-index-phrase-selection-or-word') to add |
170 |
;; the current word or selection to a special _index phrase |
;; the current word or selection to a special _index phrase |
171 |
;; file_. RefTeX can later search the document for occurrences |
;; file_. RefTeX can later search the document for occurrences |
172 |
;; of these phrases and let you interactively index the matches. |
;; of these phrases and let you interactively index the matches. |
173 |
;; |
;; |
174 |
;; * Displaying and Editing the Index |
;; * Displaying and Editing the Index |
175 |
;; To display the compiled index in a special buffer, type `C-c |
;; To display the compiled index in a special buffer, type `C-c |
176 |
;; >' (`reftex-display-index'). From that buffer you can check |
;; >' (`reftex-display-index'). From that buffer you can check |
177 |
;; and edit all entries. |
;; and edit all entries. |
178 |
;; |
;; |
179 |
;; 5. Viewing Cross-References |
;; 5. Viewing Cross-References |
180 |
;; When point is on the KEY argument of a cross-referencing macro |
;; When point is on the KEY argument of a cross-referencing macro |
181 |
;; (`\label', `\ref', `\cite', `\bibitem', `\index', and variations) |
;; (`\label', `\ref', `\cite', `\bibitem', `\index', and variations) |
185 |
;; When the enclosing macro is `\cite' or `\ref' and no other message |
;; When the enclosing macro is `\cite' or `\ref' and no other message |
186 |
;; occupies the echo area, information about the citation or label |
;; occupies the echo area, information about the citation or label |
187 |
;; will automatically be displayed in the echo area. |
;; will automatically be displayed in the echo area. |
188 |
;; |
;; |
189 |
;; 6. Multifile Documents |
;; 6. Multifile Documents |
190 |
;; Multifile Documents are fully supported. The included files must |
;; Multifile Documents are fully supported. The included files must |
191 |
;; have a file variable `TeX-master' or `tex-main-file' pointing to |
;; have a file variable `TeX-master' or `tex-main-file' pointing to |
192 |
;; the master file. RefTeX provides cross-referencing information |
;; the master file. RefTeX provides cross-referencing information |
193 |
;; from all parts of the document, and across document borders |
;; from all parts of the document, and across document borders |
194 |
;; (`xr.sty'). |
;; (`xr.sty'). |
195 |
;; |
;; |
196 |
;; 7. Document Parsing |
;; 7. Document Parsing |
197 |
;; RefTeX needs to parse the document in order to find labels and |
;; RefTeX needs to parse the document in order to find labels and |
198 |
;; other information. It does it automatically once and updates its |
;; other information. It does it automatically once and updates its |
201 |
;; with a raw `C-u' prefix, or press the `r' key in the label |
;; with a raw `C-u' prefix, or press the `r' key in the label |
202 |
;; selection buffer, the table of contents buffer, or the index |
;; selection buffer, the table of contents buffer, or the index |
203 |
;; buffer. |
;; buffer. |
204 |
;; |
;; |
205 |
;; 8. AUCTeX |
;; 8. AUCTeX |
206 |
;; If your major LaTeX mode is AUCTeX, RefTeX can cooperate with it |
;; If your major LaTeX mode is AUCTeX, RefTeX can cooperate with it |
207 |
;; (see variable `reftex-plug-into-AUCTeX'). AUCTeX contains style |
;; (see variable `reftex-plug-into-AUCTeX'). AUCTeX contains style |
208 |
;; files which trigger appropriate settings in RefTeX, so that for |
;; files which trigger appropriate settings in RefTeX, so that for |
209 |
;; many of the popular LaTeX packages no additional customizations |
;; many of the popular LaTeX packages no additional customizations |
210 |
;; will be necessary. |
;; will be necessary. |
211 |
;; |
;; |
212 |
;; 9. Useful Settings |
;; 9. Useful Settings |
213 |
;; To make RefTeX faster for large documents, try these: |
;; To make RefTeX faster for large documents, try these: |
214 |
;; (setq reftex-enable-partial-scans t) |
;; (setq reftex-enable-partial-scans t) |
215 |
;; (setq reftex-save-parse-info t) |
;; (setq reftex-save-parse-info t) |
216 |
;; (setq reftex-use-multiple-selection-buffers t) |
;; (setq reftex-use-multiple-selection-buffers t) |
217 |
;; |
;; |
218 |
;; To integrate with AUCTeX, use |
;; To integrate with AUCTeX, use |
219 |
;; (setq reftex-plug-into-AUCTeX t) |
;; (setq reftex-plug-into-AUCTeX t) |
220 |
;; |
;; |
221 |
;; To make your own LaTeX macro definitions known to RefTeX, |
;; To make your own LaTeX macro definitions known to RefTeX, |
222 |
;; customize the variables |
;; customize the variables |
223 |
;; `reftex-label-alist' (for label macros/environments) |
;; `reftex-label-alist' (for label macros/environments) |
227 |
;; `reftex-index-default-macro' (to set the default macro) |
;; `reftex-index-default-macro' (to set the default macro) |
228 |
;; If you have a large number of macros defined, you may want to write |
;; If you have a large number of macros defined, you may want to write |
229 |
;; an AUCTeX style file to support them with both AUCTeX and RefTeX. |
;; an AUCTeX style file to support them with both AUCTeX and RefTeX. |
230 |
;; |
;; |
231 |
;; 10. Where Next? |
;; 10. Where Next? |
232 |
;; Go ahead and use RefTeX. Use its menus until you have picked up |
;; Go ahead and use RefTeX. Use its menus until you have picked up |
233 |
;; the key bindings. For an overview of what you can do in each of |
;; the key bindings. For an overview of what you can do in each of |
236 |
;; The first part of the manual explains in a tutorial way how to use |
;; The first part of the manual explains in a tutorial way how to use |
237 |
;; and customize RefTeX. The second part is a command and variable |
;; and customize RefTeX. The second part is a command and variable |
238 |
;; reference. |
;; reference. |
239 |
;; |
;; |
240 |
;;--------------------------------------------------------------------------- |
;;--------------------------------------------------------------------------- |
241 |
;; |
;; |
242 |
;; AUTHOR |
;; AUTHOR |
282 |
(defvar reftex-tables-dirty t |
(defvar reftex-tables-dirty t |
283 |
"Flag showing if tables need to be re-computed.") |
"Flag showing if tables need to be re-computed.") |
284 |
|
|
|
(eval-and-compile |
|
|
(defun reftex-set-dirty (symbol value) |
|
|
(setq reftex-tables-dirty t) |
|
|
(set symbol value))) |
|
|
|
|
|
|
|
285 |
;;; ========================================================================= |
;;; ========================================================================= |
286 |
;;; |
;;; |
287 |
;;; Configuration variables |
;;; Configuration variables |
294 |
;;; Define the formal stuff for a minor mode named RefTeX. |
;;; Define the formal stuff for a minor mode named RefTeX. |
295 |
;;; |
;;; |
296 |
|
|
297 |
(defconst reftex-version "RefTeX version 4.16" |
(defconst reftex-version "RefTeX version 4.18" |
298 |
"Version string for RefTeX.") |
"Version string for RefTeX.") |
299 |
|
|
300 |
(defvar reftex-mode nil |
(defvar reftex-mode nil |
306 |
|
|
307 |
(defvar reftex-mode-menu nil) |
(defvar reftex-mode-menu nil) |
308 |
(defvar reftex-syntax-table nil) |
(defvar reftex-syntax-table nil) |
309 |
|
(defvar reftex-syntax-table-for-bib nil) |
310 |
|
|
311 |
|
(unless reftex-syntax-table |
312 |
|
(setq reftex-syntax-table (copy-syntax-table)) |
313 |
|
(modify-syntax-entry ?\( "." reftex-syntax-table) |
314 |
|
(modify-syntax-entry ?\) "." reftex-syntax-table)) |
315 |
|
|
316 |
|
(unless reftex-syntax-table-for-bib |
317 |
|
(setq reftex-syntax-table-for-bib |
318 |
|
(copy-syntax-table reftex-syntax-table)) |
319 |
|
(modify-syntax-entry ?\' "." reftex-syntax-table-for-bib) |
320 |
|
(modify-syntax-entry ?\" "." reftex-syntax-table-for-bib) |
321 |
|
(modify-syntax-entry ?\[ "." reftex-syntax-table-for-bib) |
322 |
|
(modify-syntax-entry ?\] "." reftex-syntax-table-for-bib)) |
323 |
|
|
324 |
|
;; The following definitions are out of place, but I need them here |
325 |
|
;; to make the compilation of reftex-mode not complain. |
326 |
(defvar reftex-auto-view-crossref-timer nil |
(defvar reftex-auto-view-crossref-timer nil |
327 |
"The timer used for auto-view-crossref.") |
"The timer used for auto-view-crossref.") |
328 |
|
(defvar reftex-toc-auto-recenter-timer nil |
329 |
|
"The idle timer used to recenter the toc window.") |
330 |
|
|
331 |
;;;###autoload |
;;;###autoload |
332 |
(defun turn-on-reftex () |
(defun turn-on-reftex () |
379 |
(and reftex-auto-view-crossref |
(and reftex-auto-view-crossref |
380 |
(reftex-toggle-auto-view-crossref)) |
(reftex-toggle-auto-view-crossref)) |
381 |
(put 'reftex-auto-view-crossref 'initialized t)) |
(put 'reftex-auto-view-crossref 'initialized t)) |
382 |
(unless reftex-syntax-table |
(unless (get 'reftex-auto-recenter-toc 'initialized) |
383 |
(setq reftex-syntax-table (copy-syntax-table (syntax-table))) |
(and reftex-auto-recenter-toc |
384 |
(modify-syntax-entry ?\( "." reftex-syntax-table) |
(reftex-toggle-auto-toc-recenter)) |
385 |
(modify-syntax-entry ?\) "." reftex-syntax-table)) |
(put 'reftex-auto-recenter-toc 'initialized t)) |
386 |
|
|
387 |
|
;; Prepare the special syntax tables. |
388 |
|
(setq reftex-syntax-table (copy-syntax-table (syntax-table))) |
389 |
|
(modify-syntax-entry ?\( "." reftex-syntax-table) |
390 |
|
(modify-syntax-entry ?\) "." reftex-syntax-table) |
391 |
|
|
392 |
|
(setq reftex-syntax-table-for-bib |
393 |
|
(copy-syntax-table reftex-syntax-table)) |
394 |
|
(modify-syntax-entry ?\' "." reftex-syntax-table-for-bib) |
395 |
|
(modify-syntax-entry ?\" "." reftex-syntax-table-for-bib) |
396 |
|
(modify-syntax-entry ?\[ "." reftex-syntax-table-for-bib) |
397 |
|
(modify-syntax-entry ?\] "." reftex-syntax-table-for-bib) |
398 |
|
|
399 |
(run-hooks 'reftex-mode-hook)) |
(run-hooks 'reftex-mode-hook)) |
400 |
;; Mode was turned off |
;; Mode was turned off |
401 |
(easy-menu-remove reftex-mode-menu))) |
(easy-menu-remove reftex-mode-menu))) |
529 |
((master |
((master |
530 |
(cond |
(cond |
531 |
((fboundp 'TeX-master-file) ; AUCTeX is loaded. Use its mechanism. |
((fboundp 'TeX-master-file) ; AUCTeX is loaded. Use its mechanism. |
532 |
(condition-case nil |
(condition-case nil |
533 |
(TeX-master-file t) |
(TeX-master-file t) |
534 |
(error (buffer-file-name)))) |
(error (buffer-file-name)))) |
535 |
((fboundp 'tex-main-file) (tex-main-file)) ; Emacs LaTeX mode |
((fboundp 'tex-main-file) (tex-main-file)) ; Emacs LaTeX mode |
558 |
(buffer-file-name))))) |
(buffer-file-name))))) |
559 |
(cond |
(cond |
560 |
((null master) |
((null master) |
561 |
(error "Need a filename for this buffer, please save it first")) |
(error "Need a filename for this buffer, please save it first")) |
562 |
((or (file-exists-p (concat master ".tex")) |
((or (file-exists-p (concat master ".tex")) |
563 |
(reftex-get-buffer-visiting (concat master ".tex"))) |
(reftex-get-buffer-visiting (concat master ".tex"))) |
564 |
;; Ahh, an extra .tex was missing... |
;; Ahh, an extra .tex was missing... |
569 |
) |
) |
570 |
(t |
(t |
571 |
;; Use buffer file name. |
;; Use buffer file name. |
572 |
(buffer-file-name))) |
(setq master (buffer-file-name)))) |
573 |
(expand-file-name master))) |
(expand-file-name master))) |
574 |
|
|
575 |
(defun reftex-is-multi () |
(defun reftex-is-multi () |
635 |
;; The following constants are derived from `reftex-label-alist'. |
;; The following constants are derived from `reftex-label-alist'. |
636 |
|
|
637 |
;; Prompt used for label type queries directed to the user. |
;; Prompt used for label type queries directed to the user. |
638 |
(defconst reftex-type-query-prompt nil) |
(defvar reftex-type-query-prompt nil) |
639 |
|
|
640 |
;; Help string for label type queries. |
;; Help string for label type queries. |
641 |
(defconst reftex-type-query-help nil) |
(defvar reftex-type-query-help nil) |
642 |
|
|
643 |
;; Alist relating label type to reference format. |
;; Alist relating label type to reference format. |
644 |
(defconst reftex-typekey-to-format-alist nil) |
(defvar reftex-typekey-to-format-alist nil) |
645 |
|
|
646 |
;; Alist relating label type to label prefix. |
;; Alist relating label type to label prefix. |
647 |
(defconst reftex-typekey-to-prefix-alist nil) |
(defvar reftex-typekey-to-prefix-alist nil) |
648 |
|
|
649 |
;; Alist relating environments or macros to label type and context regexp. |
;; Alist relating environments or macros to label type and context regexp. |
650 |
(defconst reftex-env-or-mac-alist nil) |
(defvar reftex-env-or-mac-alist nil) |
651 |
|
|
652 |
;; List of special environment parser functions |
;; List of special environment parser functions |
653 |
(defconst reftex-special-env-parsers nil) |
(defvar reftex-special-env-parsers nil) |
654 |
|
|
655 |
;; List of macros carrying a label. |
;; List of macros carrying a label. |
656 |
(defconst reftex-label-mac-list nil) |
(defvar reftex-label-mac-list nil) |
657 |
|
|
658 |
;; List of environments carrying a label. |
;; List of environments carrying a label. |
659 |
(defconst reftex-label-env-list nil) |
(defvar reftex-label-env-list nil) |
660 |
|
|
661 |
;; List of all typekey letters in use. |
;; List of all typekey letters in use. |
662 |
(defconst reftex-typekey-list nil) |
(defvar reftex-typekey-list nil) |
663 |
|
|
664 |
;; Alist relating magic words to a label type. |
;; Alist relating magic words to a label type. |
665 |
(defconst reftex-words-to-typekey-alist nil) |
(defvar reftex-words-to-typekey-alist nil) |
666 |
|
|
667 |
;; The last list-of-labels entry used in a reference. |
;; The last list-of-labels entry used in a reference. |
668 |
(defvar reftex-last-used-reference (list nil nil nil nil)) |
(defvar reftex-last-used-reference (list nil nil nil nil)) |
669 |
|
|
670 |
;; Alist relating index macros to other info. |
;; Alist relating index macros to other info. |
671 |
(defconst reftex-key-to-index-macro-alist nil) |
(defvar reftex-key-to-index-macro-alist nil) |
672 |
;; Prompt for index macro queries |
;; Prompt for index macro queries |
673 |
(defconst reftex-query-index-macro-prompt nil) |
(defvar reftex-query-index-macro-prompt nil) |
674 |
;; Help string for index macro queries |
;; Help string for index macro queries |
675 |
(defconst reftex-query-index-macro-help nil) |
(defvar reftex-query-index-macro-help nil) |
676 |
|
|
677 |
;; The message when follow-mode is suspended |
;; The message when follow-mode is suspended |
678 |
(defconst reftex-no-follow-message |
(defvar reftex-no-follow-message |
679 |
"No follow-mode into unvisited file. Press SPC to visit it.") |
"No follow-mode into unvisited file. Press SPC to visit it.") |
680 |
(defconst reftex-no-info-message |
(defvar reftex-no-info-message |
681 |
"%s: info not available, use `\\[reftex-view-crossref]' to get it.") |
"%s: info not available, use `\\[reftex-view-crossref]' to get it.") |
682 |
|
|
683 |
;; Global variables used for communication between functions. |
;; Global variables used for communication between functions. |
697 |
(defvar reftex-callback-fwd t) |
(defvar reftex-callback-fwd t) |
698 |
(defvar reftex-last-toc-master nil |
(defvar reftex-last-toc-master nil |
699 |
"Stores the name of the tex file that `reftex-toc' was last run on.") |
"Stores the name of the tex file that `reftex-toc' was last run on.") |
|
(defvar reftex-auto-view-crossref-timer nil |
|
|
"The timer used for auto-view-crossref.") |
|
700 |
;; Marker for return point from recursive edit |
;; Marker for return point from recursive edit |
701 |
(defvar reftex-recursive-edit-marker (make-marker)) |
(defvar reftex-recursive-edit-marker (make-marker)) |
702 |
|
|
728 |
|
|
729 |
;; A list of all variables in the cache. |
;; A list of all variables in the cache. |
730 |
;; The cache is used to save the compiled versions of some variables. |
;; The cache is used to save the compiled versions of some variables. |
731 |
(defconst reftex-cache-variables |
(defconst reftex-cache-variables |
732 |
'(reftex-memory ;; This MUST ALWAYS be the first! |
'(reftex-memory ;; This MUST ALWAYS be the first! |
733 |
|
|
734 |
;; Outline |
;; Outline |
735 |
reftex-section-levels-all |
reftex-section-levels-all |
736 |
|
|
737 |
;; Labels |
;; Labels |
738 |
reftex-env-or-mac-alist |
reftex-env-or-mac-alist |
739 |
reftex-special-env-parsers |
reftex-special-env-parsers |
740 |
reftex-macros-with-labels |
reftex-macros-with-labels |
741 |
reftex-label-mac-list |
reftex-label-mac-list |
751 |
reftex-index-macro-alist |
reftex-index-macro-alist |
752 |
reftex-macros-with-index |
reftex-macros-with-index |
753 |
reftex-query-index-macro-prompt |
reftex-query-index-macro-prompt |
754 |
reftex-query-index-macro-help |
reftex-query-index-macro-help |
755 |
reftex-key-to-index-macro-alist |
reftex-key-to-index-macro-alist |
756 |
|
|
757 |
;; Regular expressions |
;; Regular expressions |
796 |
(t (reftex-compile-variables))))) |
(t (reftex-compile-variables))))) |
797 |
|
|
798 |
(defun reftex-reset-mode () |
(defun reftex-reset-mode () |
799 |
"Reset RefTeX Mode. |
"Reset RefTeX Mode. |
800 |
This will re-compile the configuration information and remove all |
This will re-compile the configuration information and remove all |
801 |
current scanning information and the parse file to enforce a rescan |
current scanning information and the parse file to enforce a rescan |
802 |
on next use." |
on next use." |
846 |
|
|
847 |
(defun reftex-erase-all-selection-and-index-buffers () |
(defun reftex-erase-all-selection-and-index-buffers () |
848 |
;; Remove all selection buffers associated with current document. |
;; Remove all selection buffers associated with current document. |
849 |
(mapcar |
(mapcar |
850 |
(lambda (type) |
(lambda (type) |
851 |
(reftex-erase-buffer (reftex-make-selection-buffer-name type))) |
(reftex-erase-buffer (reftex-make-selection-buffer-name type))) |
852 |
reftex-typekey-list) |
reftex-typekey-list) |
853 |
;; Kill all index buffers |
;; Kill all index buffers |
854 |
(mapcar |
(mapcar |
855 |
(lambda (tag) |
(lambda (tag) |
856 |
(reftex-kill-buffer (reftex-make-index-buffer-name tag))) |
(reftex-kill-buffer (reftex-make-index-buffer-name tag))) |
857 |
(cdr (assoc 'index-tags (symbol-value reftex-docstruct-symbol))))) |
(cdr (assoc 'index-tags (symbol-value reftex-docstruct-symbol))))) |
867 |
|
|
868 |
;; Record that we have done this, and what we have used. |
;; Record that we have done this, and what we have used. |
869 |
(setq reftex-tables-dirty nil) |
(setq reftex-tables-dirty nil) |
870 |
(setq reftex-memory |
(setq reftex-memory |
871 |
(list reftex-label-alist |
(list reftex-label-alist |
872 |
(get reftex-docstruct-symbol 'reftex-section-levels) |
(get reftex-docstruct-symbol 'reftex-section-levels) |
873 |
(get reftex-docstruct-symbol 'reftex-label-alist-style) |
(get reftex-docstruct-symbol 'reftex-label-alist-style) |
886 |
'(nil))) |
'(nil))) |
887 |
(all-index (reftex-uniquify-by-car |
(all-index (reftex-uniquify-by-car |
888 |
(reftex-splice-symbols-into-list |
(reftex-splice-symbols-into-list |
889 |
(append reftex-index-macros |
(append reftex-index-macros |
890 |
(get reftex-docstruct-symbol |
(get reftex-docstruct-symbol |
891 |
'reftex-index-macros-style) |
'reftex-index-macros-style) |
892 |
'(default)) |
'(default)) |
947 |
((symbolp env-or-mac) |
((symbolp env-or-mac) |
948 |
;; A special parser function |
;; A special parser function |
949 |
(unless (fboundp env-or-mac) |
(unless (fboundp env-or-mac) |
950 |
(message "Warning: %s does not seem to be a valid function" |
(message "Warning: %s does not seem to be a valid function" |
951 |
env-or-mac)) |
env-or-mac)) |
952 |
(setq nargs nil nlabel nil opt-args nil) |
(setq nargs nil nlabel nil opt-args nil) |
953 |
(add-to-list 'reftex-special-env-parsers env-or-mac) |
(add-to-list 'reftex-special-env-parsers env-or-mac) |
975 |
(push (cons string toc-level) toc-levels)))))))) |
(push (cons string toc-level) toc-levels)))))))) |
976 |
;; Translate some special context cases |
;; Translate some special context cases |
977 |
(when (assq context reftex-default-context-regexps) |
(when (assq context reftex-default-context-regexps) |
978 |
(setq context |
(setq context |
979 |
(format |
(format |
980 |
(cdr (assq context reftex-default-context-regexps)) |
(cdr (assq context reftex-default-context-regexps)) |
981 |
(regexp-quote env-or-mac)))) |
(regexp-quote env-or-mac)))) |
982 |
;; See if this is the first format for this typekey |
;; See if this is the first format for this typekey |
1009 |
(nreverse reftex-typekey-to-prefix-alist)) |
(nreverse reftex-typekey-to-prefix-alist)) |
1010 |
|
|
1011 |
;; Prepare the typekey query prompt and help string. |
;; Prepare the typekey query prompt and help string. |
1012 |
(setq qh-list |
(setq qh-list |
1013 |
(sort qh-list |
(sort qh-list |
1014 |
(lambda (x1 x2) |
(lambda (x1 x2) |
1015 |
(string< (downcase (car x1)) (downcase (car x2)))))) |
(string< (downcase (car x1)) (downcase (car x2)))))) |
1020 |
"]")) |
"]")) |
1021 |
;; In the help string, we need to wrap lines... |
;; In the help string, we need to wrap lines... |
1022 |
(setq reftex-type-query-help |
(setq reftex-type-query-help |
1023 |
(concat |
(concat |
1024 |
"SELECT A LABEL TYPE:\n--------------------\n" |
"SELECT A LABEL TYPE:\n--------------------\n" |
1025 |
(mapconcat |
(mapconcat |
1026 |
(lambda(x) |
(lambda(x) |
1040 |
;; which allow for some chars from the ref format to be in the buffer. |
;; which allow for some chars from the ref format to be in the buffer. |
1041 |
;; These characters will be seen and removed. |
;; These characters will be seen and removed. |
1042 |
(setq reftex-words-to-typekey-alist |
(setq reftex-words-to-typekey-alist |
1043 |
(mapcar |
(mapcar |
1044 |
(lambda (x) |
(lambda (x) |
1045 |
(setq word (car x) |
(setq word (car x) |
1046 |
typekey (cdr x) |
typekey (cdr x) |
1093 |
(setq reftex-key-to-index-macro-alist |
(setq reftex-key-to-index-macro-alist |
1094 |
(sort reftex-key-to-index-macro-alist |
(sort reftex-key-to-index-macro-alist |
1095 |
(lambda (a b) (< (downcase (car a)) (downcase (car b)))))) |
(lambda (a b) (< (downcase (car a)) (downcase (car b)))))) |
1096 |
(setq reftex-query-index-macro-prompt |
(setq reftex-query-index-macro-prompt |
1097 |
(concat "Index macro: [" |
(concat "Index macro: [" |
1098 |
(mapconcat (lambda (x) (char-to-string (car x))) |
(mapconcat (lambda (x) (char-to-string (car x))) |
1099 |
reftex-key-to-index-macro-alist "") |
reftex-key-to-index-macro-alist "") |
1100 |
"]")) |
"]")) |
1101 |
(setq i 0 |
(setq i 0 |
1102 |
reftex-query-index-macro-help |
reftex-query-index-macro-help |
1103 |
(concat |
(concat |
1104 |
"SELECT A MACRO:\n---------------\n" |
"SELECT A MACRO:\n---------------\n" |
1105 |
(mapconcat |
(mapconcat |
1106 |
(lambda(x) |
(lambda(x) |
1107 |
(format "[%c] %-20.20s%s" (car x) (nth 1 x) |
(format "[%c] %-20.20s%s" (car x) (nth 1 x) |
1108 |
(if (= 0 (mod (incf i) 3)) "\n" ""))) |
(if (= 0 (mod (incf i) 3)) "\n" ""))) |
1109 |
reftex-key-to-index-macro-alist ""))) |
reftex-key-to-index-macro-alist ""))) |
1110 |
|
|
1115 |
reftex-section-levels)) |
reftex-section-levels)) |
1116 |
|
|
1117 |
;; Calculate the regular expressions |
;; Calculate the regular expressions |
1118 |
(let* ((wbol "\\(\\`\\|[\n\r]\\)[ \t]*") |
(let* ( |
1119 |
|
; (wbol "\\(\\`\\|[\n\r]\\)[ \t]*") |
1120 |
|
(wbol "\\(^\\)[ \t]*") ; Need to keep the empty group because |
1121 |
|
;;; because match number are hard coded |
1122 |
(label-re "\\\\label{\\([^}]*\\)}") |
(label-re "\\\\label{\\([^}]*\\)}") |
1123 |
(include-re (concat wbol "\\\\\\(include\\|input\\)[{ \t]+\\([^} \t\n\r]+\\)")) |
(include-re (concat wbol |
1124 |
|
"\\\\\\(" |
1125 |
|
(mapconcat 'identity |
1126 |
|
reftex-include-file-commands "\\|") |
1127 |
|
"\\)[{ \t]+\\([^} \t\n\r]+\\)")) |
1128 |
(section-re |
(section-re |
1129 |
(concat wbol "\\\\\\(" |
(concat wbol "\\\\\\(" |
1130 |
(mapconcat (lambda (x) (regexp-quote (car x))) |
(mapconcat (lambda (x) (regexp-quote (car x))) |
1176 |
reftex-macros-with-labels macros-with-labels |
reftex-macros-with-labels macros-with-labels |
1177 |
reftex-find-index-entry-regexp-format find-index-re-format |
reftex-find-index-entry-regexp-format find-index-re-format |
1178 |
reftex-find-label-regexp-format find-label-re-format |
reftex-find-label-regexp-format find-label-re-format |
1179 |
reftex-find-label-regexp-format2 |
reftex-find-label-regexp-format2 |
1180 |
"\\([]} \t\n\r]\\)\\([[{]\\)\\(%s\\)[]}]") |
"\\([]} \t\n\r]\\)\\([[{]\\)\\(%s\\)[]}]") |
1181 |
(message "Compiling label environment definitions...done"))) |
(message "Compiling label environment definitions...done"))) |
1182 |
(put reftex-docstruct-symbol 'reftex-cache |
(put reftex-docstruct-symbol 'reftex-cache |
1248 |
(and (symbolp reftex-docstruct-symbol) |
(and (symbolp reftex-docstruct-symbol) |
1249 |
(symbol-value reftex-docstruct-symbol) |
(symbol-value reftex-docstruct-symbol) |
1250 |
t)) |
t)) |
1251 |
|
|
1252 |
(defun reftex-silence-toc-markers (list n) |
(defun reftex-silence-toc-markers (list n) |
1253 |
;; Set all toc markers in the first N entries in list to nil |
;; Set all toc markers in the first N entries in list to nil |
1254 |
(while (and list (> (decf n) -1)) |
(while (and list (> (decf n) -1)) |
1265 |
(master (reftex-TeX-master-file)) |
(master (reftex-TeX-master-file)) |
1266 |
(enable-local-variables nil) |
(enable-local-variables nil) |
1267 |
(file (if (string-match "\\.[a-zA-Z]+\\'" master) |
(file (if (string-match "\\.[a-zA-Z]+\\'" master) |
1268 |
(concat (substring master 0 (match-beginning 0)) |
(concat (substring master 0 (match-beginning 0)) |
1269 |
reftex-parse-file-extension) |
reftex-parse-file-extension) |
1270 |
(concat master reftex-parse-file-extension)))) |
(concat master reftex-parse-file-extension)))) |
1271 |
(cond |
(cond |
1344 |
|
|
1345 |
;; Check if the master is the same: when moving a document, this will see it. |
;; Check if the master is the same: when moving a document, this will see it. |
1346 |
(let* ((real-master (reftex-TeX-master-file)) |
(let* ((real-master (reftex-TeX-master-file)) |
1347 |
(parsed-master |
(parsed-master |
1348 |
(nth 1 (assq 'bof (symbol-value reftex-docstruct-symbol))))) |
(nth 1 (assq 'bof (symbol-value reftex-docstruct-symbol))))) |
1349 |
(unless (string= (file-truename real-master) (file-truename parsed-master)) |
(unless (string= (file-truename real-master) (file-truename parsed-master)) |
1350 |
(message "Master file name in load file is different: %s versus %s" |
(message "Master file name in load file is different: %s versus %s" |
1364 |
(defun reftex-select-external-document (xr-alist xr-index) |
(defun reftex-select-external-document (xr-alist xr-index) |
1365 |
;; Return index of an external document. |
;; Return index of an external document. |
1366 |
(let* ((len (length xr-alist)) (highest (1- (+ ?0 len))) |
(let* ((len (length xr-alist)) (highest (1- (+ ?0 len))) |
1367 |
(prompt (format "[%c-%c] Select TAB: Read prefix with completion" |
(prompt (format "[%c-%c] Select TAB: Read prefix with completion" |
1368 |
?0 highest)) |
?0 highest)) |
1369 |
key prefix) |
key prefix) |
1370 |
(cond |
(cond |
1375 |
(- 1 xr-index)) |
(- 1 xr-index)) |
1376 |
(t |
(t |
1377 |
(save-excursion |
(save-excursion |
1378 |
(let* ((length (apply 'max (mapcar |
(let* ((length (apply 'max (mapcar |
1379 |
(lambda(x) (length (car x))) xr-alist))) |
(lambda(x) (length (car x))) xr-alist))) |
1380 |
(fmt (format " [%%c] %%-%ds %%s\n" length)) |
(fmt (format " [%%c] %%-%ds %%s\n" length)) |
1381 |
(n (1- ?0))) |
(n (1- ?0))) |
1385 |
(concat |
(concat |
1386 |
"SELECT EXTERNAL DOCUMENT\n------------------------\n" |
"SELECT EXTERNAL DOCUMENT\n------------------------\n" |
1387 |
(mapconcat |
(mapconcat |
1388 |
(lambda (x) |
(lambda (x) |
1389 |
(format fmt (incf n) (or (car x) "") |
(format fmt (incf n) (or (car x) "") |
1390 |
(abbreviate-file-name (cdr x)))) |
(abbreviate-file-name (cdr x)))) |
1391 |
xr-alist "")) |
xr-alist "")) |
1409 |
(let* ((rec-values (if reftex-search-unrecursed-path-first '(nil t) '(t))) |
(let* ((rec-values (if reftex-search-unrecursed-path-first '(nil t) '(t))) |
1410 |
(extensions (cdr (assoc type reftex-file-extensions))) |
(extensions (cdr (assoc type reftex-file-extensions))) |
1411 |
(def-ext (car extensions)) |
(def-ext (car extensions)) |
1412 |
(ext-re (concat "\\(" |
(ext-re (concat "\\(" |
1413 |
(mapconcat 'regexp-quote extensions "\\|") |
(mapconcat 'regexp-quote extensions "\\|") |
1414 |
"\\)\\'")) |
"\\)\\'")) |
1415 |
(files (if (string-match ext-re file) |
(files (if (string-match ext-re file) |
1418 |
path old-path file1) |
path old-path file1) |
1419 |
(cond |
(cond |
1420 |
((file-name-absolute-p file) |
((file-name-absolute-p file) |
1421 |
(setq file1 |
(setq file1 |
1422 |
(or |
(or |
1423 |
(and (car files) (file-regular-p (car files)) (car files)) |
(and (car files) (file-regular-p (car files)) (car files)) |
1424 |
(and (cdr files) (file-regular-p (cdr files)) (cdr files))))) |
(and (cdr files) (file-regular-p (cdr files)) (cdr files))))) |
1425 |
((and reftex-use-external-file-finders |
((and reftex-use-external-file-finders |
1434 |
(setq old-path path |
(setq old-path path |
1435 |
path (cons master-dir path) |
path (cons master-dir path) |
1436 |
file1 (or (and (car files) |
file1 (or (and (car files) |
1437 |
(reftex-find-file-on-path |
(reftex-find-file-on-path |
1438 |
(car files) path master-dir)) |
(car files) path master-dir)) |
1439 |
(and (cdr files) |
(and (cdr files) |
1440 |
(reftex-find-file-on-path |
(reftex-find-file-on-path |
1441 |
(cdr files) path master-dir)))))))) |
(cdr files) path master-dir)))))))) |
1442 |
(cond (file1 file1) |
(cond (file1 file1) |
1443 |
(die (error "No such file: %s" file) nil) |
(die (error "No such file: %s" file) nil) |
1482 |
(reftex-uniq |
(reftex-uniq |
1483 |
(reftex-parse-colon-path |
(reftex-parse-colon-path |
1484 |
(mapconcat |
(mapconcat |
1485 |
(lambda(x) |
(lambda(x) |
1486 |
(if (string-match "^!" x) |
(if (string-match "^!" x) |
1487 |
(apply 'reftex-process-string |
(apply 'reftex-process-string |
1488 |
(split-string (substring x 1))) |
(split-string (substring x 1))) |
1491 |
;; (cdr (assoc type reftex-path-environment)) |
;; (cdr (assoc type reftex-path-environment)) |
1492 |
;; However, historically we have separate options for the |
;; However, historically we have separate options for the |
1493 |
;; environment variables, so we have to do this: |
;; environment variables, so we have to do this: |
1494 |
(symbol-value (intern (concat "reftex-" type |
(symbol-value (intern (concat "reftex-" type |
1495 |
"path-environment-variables"))) |
"path-environment-variables"))) |
1496 |
path-separator)))) |
path-separator)))) |
1497 |
(put pathvar 'status 'split) |
(put pathvar 'status 'split) |
1517 |
;; or: Relative recursive path elements need to be expanded |
;; or: Relative recursive path elements need to be expanded |
1518 |
;; relative to new default directory |
;; relative to new default directory |
1519 |
(message "Expanding search path to find %s file: %s ..." type file) |
(message "Expanding search path to find %s file: %s ..." type file) |
1520 |
(put pathvar 'recursive-path |
(put pathvar 'recursive-path |
1521 |
(reftex-expand-path (symbol-value pathvar) master-dir)) |
(reftex-expand-path (symbol-value pathvar) master-dir)) |
1522 |
(put pathvar 'master-dir master-dir) |
(put pathvar 'master-dir master-dir) |
1523 |
(get pathvar 'recursive-path)) |
(get pathvar 'recursive-path)) |
1524 |
(t |
(t |
1525 |
;; Recursive path computed earlier is still OK. |
;; Recursive path computed earlier is still OK. |
1526 |
(get pathvar 'recursive-path))) |
(get pathvar 'recursive-path))) |
1527 |
;; The simple path was requested |
;; The simple path was requested |
1550 |
;; Trailing ! or !! will be converted into `//' (emTeX convention) |
;; Trailing ! or !! will be converted into `//' (emTeX convention) |
1551 |
(mapcar |
(mapcar |
1552 |
(lambda (dir) |
(lambda (dir) |
1553 |
(if (string-match "\\(//+\\|/*!+\\)\\'" dir) |
(if (string-match "\\(//+\\|/*!+\\)\\'" dir) |
1554 |
(setq dir (replace-match "//" t t dir))) |
(setq dir (replace-match "//" t t dir))) |
1555 |
(file-name-as-directory dir)) |
(file-name-as-directory dir)) |
1556 |
(delete "" (split-string path (concat path-separator "+"))))) |
(delete "" (split-string path (concat path-separator "+"))))) |
1579 |
(when (file-directory-p dir) |
(when (file-directory-p dir) |
1580 |
(setq files (nreverse (directory-files dir t "[^.]"))) |
(setq files (nreverse (directory-files dir t "[^.]"))) |
1581 |
(while (setq file (pop files)) |
(while (setq file (pop files)) |
1582 |
(if (file-directory-p file) |
(if (file-directory-p file) |
1583 |
(push (file-name-as-directory file) path))) |
(push (file-name-as-directory file) path))) |
1584 |
(push dir path1))) |
(push dir path1))) |
1585 |
path1)) |
path1)) |
1641 |
"Make a fancyref \\Fref reference." t) |
"Make a fancyref \\Fref reference." t) |
1642 |
(autoload 'reftex-show-label-location "reftex-ref") |
(autoload 'reftex-show-label-location "reftex-ref") |
1643 |
(autoload 'reftex-query-label-type "reftex-ref") |
(autoload 'reftex-query-label-type "reftex-ref") |
1644 |
|
(autoload 'reftex-goto-label "reftex-ref" |
1645 |
|
"Prompt for label name and go to that location." t) |
1646 |
|
|
1647 |
;;; ========================================================================= |
;;; ========================================================================= |
1648 |
;;; |
;;; |
1649 |
;;; Table of contents |
;;; Table of contents |
1650 |
|
|
1651 |
(autoload 'reftex-toc "reftex-toc" |
(autoload 'reftex-toc "reftex-toc" |
1652 |
"Show the table of contents for the current document." t) |
"Show the table of contents for the current document." t) |
1653 |
|
(autoload 'reftex-toc-recenter "reftex-toc" |
1654 |
|
"Display the TOC window and highlight line corresponding to current position." t) |
1655 |
|
(autoload 'reftex-toggle-auto-toc-recenter "reftex-toc" t) |
1656 |
|
|
1657 |
|
|
1658 |
;;; ========================================================================= |
;;; ========================================================================= |
1669 |
(autoload 'reftex-citation "reftex-cite" |
(autoload 'reftex-citation "reftex-cite" |
1670 |
"Make a citation using BibTeX database files." t) |
"Make a citation using BibTeX database files." t) |
1671 |
(autoload 'reftex-default-bibliography "reftex-cite") |
(autoload 'reftex-default-bibliography "reftex-cite") |
1672 |
|
(autoload 'reftex-bib-or-thebib "reftex-cite") |
1673 |
|
|
1674 |
;;; ========================================================================= |
;;; ========================================================================= |
1675 |
;;; |
;;; |
1863 |
(while list |
(while list |
1864 |
(if (funcall predicate (car list)) |
(if (funcall predicate (car list)) |
1865 |
(push (if completion |
(push (if completion |
1866 |
(list (nth nth (car list))) |
(list (nth nth (car list))) |
1867 |
(nth nth (car list))) |
(nth nth (car list))) |
1868 |
rtn)) |
rtn)) |
1869 |
(setq list (cdr list))) |
(setq list (cdr list))) |
1899 |
;; If POS is given, calculate distances relative to it. |
;; If POS is given, calculate distances relative to it. |
1900 |
;; Return nil if there is no match. |
;; Return nil if there is no match. |
1901 |
(let ((pos (point)) |
(let ((pos (point)) |
1902 |
(dist (or max-length (length regexp))) |
(dist (or max-length (length regexp))) |
1903 |
match1 match2 match) |
match1 match2 match) |
1904 |
(goto-char (min (+ pos dist) (point-max))) |
(goto-char (min (+ pos dist) (point-max))) |
1905 |
(when (re-search-backward regexp nil t) |
(when (re-search-backward regexp nil t) |
1985 |
((and scroll (equal char ?\C-? )) |
((and scroll (equal char ?\C-? )) |
1986 |
(condition-case nil (scroll-down) (error nil)) |
(condition-case nil (scroll-down) (error nil)) |
1987 |
(message prompt)) |
(message prompt)) |
1988 |
(t (message "") |
(t (message "") |
1989 |
(throw 'exit char))) |
(throw 'exit char))) |
1990 |
(setq char (read-char-exclusive))))))) |
(setq char (read-char-exclusive))))))) |
1991 |
|
|
1992 |
|
|
1993 |
(defun reftex-make-regexp-allow-for-ctrl-m (string) |
(defun reftex-make-regexp-allow-for-ctrl-m (string) |
1994 |
;; convert STRING into a regexp, allowing ^M for \n and vice versa |
;; convert STRING into a regexp, allowing ^M for \n and vice versa |
2186 |
;; Restrict number of words |
;; Restrict number of words |
2187 |
(if (> (length words) nwords) |
(if (> (length words) nwords) |
2188 |
(setcdr (nthcdr (1- nwords) words) nil)) |
(setcdr (nthcdr (1- nwords) words) nil)) |
2189 |
|
|
2190 |
;; First, try to use all words |
;; First, try to use all words |
2191 |
(setq string (mapconcat 'identity words sep)) |
(setq string (mapconcat 'identity words sep)) |
2192 |
|
|
2193 |
;; Abbreviate words if enforced by user settings or string length |
;; Abbreviate words if enforced by user settings or string length |
2194 |
(if (or (eq t abbrev) |
(if (or (eq t abbrev) |
2195 |
(and abbrev |
(and abbrev |
2281 |
(font-lock-set-defaults-1) |
(font-lock-set-defaults-1) |
2282 |
(reftex-select-font-lock-fontify-region (point-min) (point-max)))) |
(reftex-select-font-lock-fontify-region (point-min) (point-max)))) |
2283 |
(t |
(t |
2284 |
;; Oops? |
;; Oops? |
2285 |
(message "Sorry: cannot refontify RefTeX Select buffer.")))) |
(message "Sorry: cannot refontify RefTeX Select buffer.")))) |
2286 |
(rename-buffer oldname)))) |
(rename-buffer oldname)))) |
2287 |
|
|
2317 |
(if (featurep 'xemacs) (require 'overlay)) |
(if (featurep 'xemacs) (require 'overlay)) |
2318 |
|
|
2319 |
;; We keep a vector with several different overlays to do our highlighting. |
;; We keep a vector with several different overlays to do our highlighting. |
2320 |
(defvar reftex-highlight-overlays [nil nil]) |
(defvar reftex-highlight-overlays [nil nil nil]) |
2321 |
|
|
2322 |
;; Initialize the overlays |
;; Initialize the overlays |
2323 |
(aset reftex-highlight-overlays 0 (make-overlay 1 1)) |
(aset reftex-highlight-overlays 0 (make-overlay 1 1)) |
2324 |
(overlay-put (aref reftex-highlight-overlays 0) |
(overlay-put (aref reftex-highlight-overlays 0) |
2325 |
'face 'highlight) |
'face 'highlight) |
2326 |
(aset reftex-highlight-overlays 1 (make-overlay 1 1)) |
(aset reftex-highlight-overlays 1 (make-overlay 1 1)) |
2327 |
(overlay-put (aref reftex-highlight-overlays 1) |
(overlay-put (aref reftex-highlight-overlays 1) |
2328 |
'face reftex-cursor-selected-face) |
'face reftex-cursor-selected-face) |
2329 |
|
(aset reftex-highlight-overlays 2 (make-overlay 1 1)) |
2330 |
|
(overlay-put (aref reftex-highlight-overlays 2) |
2331 |
|
'face reftex-cursor-selected-face) |
2332 |
|
|
2333 |
;; Two functions for activating and deactivation highlight overlays |
;; Two functions for activating and deactivation highlight overlays |
2334 |
(defun reftex-highlight (index begin end &optional buffer) |
(defun reftex-highlight (index begin end &optional buffer) |
2346 |
|
|
2347 |
;;; ========================================================================= |
;;; ========================================================================= |
2348 |
;;; |
;;; |
2349 |
;;; Keybindings |
;;; Keybindings |
2350 |
|
|
2351 |
;; The default bindings in the mode map. |
;; The default bindings in the mode map. |
2352 |
(loop for x in |
(loop for x in |
2353 |
'(("\C-c=" . reftex-toc) |
'(("\C-c=" . reftex-toc) |
2354 |
|
("\C-c-" . reftex-toc-recenter) |
2355 |
("\C-c(" . reftex-label) |
("\C-c(" . reftex-label) |
2356 |
("\C-c)" . reftex-reference) |
("\C-c)" . reftex-reference) |
2357 |
("\C-c[" . reftex-citation) |
("\C-c[" . reftex-citation) |
2366 |
;; Bind `reftex-mouse-view-crossref' only when the key is still free |
;; Bind `reftex-mouse-view-crossref' only when the key is still free |
2367 |
(if (featurep 'xemacs) |
(if (featurep 'xemacs) |
2368 |
(unless (key-binding [(shift button2)]) |
(unless (key-binding [(shift button2)]) |
2369 |
(define-key reftex-mode-map [(shift button2)] |
(define-key reftex-mode-map [(shift button2)] |
2370 |
'reftex-mouse-view-crossref)) |
'reftex-mouse-view-crossref)) |
2371 |
(unless (key-binding [(shift mouse-2)]) |
(unless (key-binding [(shift mouse-2)]) |
2372 |
(define-key reftex-mode-map [(shift mouse-2)] |
(define-key reftex-mode-map [(shift mouse-2)] |
2373 |
'reftex-mouse-view-crossref))) |
'reftex-mouse-view-crossref))) |
2374 |
|
|
2375 |
;; Bind `reftex-view-crossref-from-bibtex' in BibTeX mode map |
;; Bind `reftex-view-crossref-from-bibtex' in BibTeX mode map |
2401 |
"Menu used in RefTeX mode" |
"Menu used in RefTeX mode" |
2402 |
`("Ref" |
`("Ref" |
2403 |
["Table of Contents" reftex-toc t] |
["Table of Contents" reftex-toc t] |
2404 |
|
["Recenter TOC" reftex-toc-recenter t] |
2405 |
"--" |
"--" |
2406 |
["\\label" reftex-label t] |
["\\label" reftex-label t] |
2407 |
["\\ref" reftex-reference t] |
["\\ref" reftex-reference t] |
2423 |
["Entire Document" reftex-parse-all t] |
["Entire Document" reftex-parse-all t] |
2424 |
["Save to File" (reftex-access-parse-file 'write) |
["Save to File" (reftex-access-parse-file 'write) |
2425 |
(> (length (symbol-value reftex-docstruct-symbol)) 0)] |
(> (length (symbol-value reftex-docstruct-symbol)) 0)] |
2426 |
["Restore from File" (reftex-access-parse-file 'restore) t] |
["Restore from File" (reftex-access-parse-file 'restore) t]) |
|
"--" |
|
|
["Reset RefTeX Mode" reftex-reset-mode t]) |
|
2427 |
("Global Actions" |
("Global Actions" |
2428 |
["Search Whole Document" reftex-search-document t] |
["Search Whole Document" reftex-search-document t] |
2429 |
["Replace in Document" reftex-query-replace-document t] |
["Replace in Document" reftex-query-replace-document t] |
2430 |
["Grep on Document" reftex-grep-document t] |
["Grep on Document" reftex-grep-document t] |
2431 |
"--" |
"--" |
2432 |
|
["Goto Label" reftex-goto-label t] |
2433 |
["Find Duplicate Labels" reftex-find-duplicate-labels t] |
["Find Duplicate Labels" reftex-find-duplicate-labels t] |
2434 |
["Change Label and Refs" reftex-change-label t] |
["Change Label and Refs" reftex-change-label t] |
2435 |
["Renumber Simple Labels" reftex-renumber-simple-labels t] |
["Renumber Simple Labels" reftex-renumber-simple-labels t] |
2447 |
(setq reftex-save-parse-info (not reftex-save-parse-info)) |
(setq reftex-save-parse-info (not reftex-save-parse-info)) |
2448 |
:style toggle :selected reftex-save-parse-info] |
:style toggle :selected reftex-save-parse-info] |
2449 |
"--" |
"--" |
2450 |
|
"TOC RECENTER" |
2451 |
|
["Automatic Recenter" reftex-toggle-auto-toc-recenter |
2452 |
|
:style toggle :selected reftex-toc-auto-recenter-timer] |
2453 |
|
"--" |
2454 |
"CROSSREF INFO" |
"CROSSREF INFO" |
2455 |
["Automatic Info" reftex-toggle-auto-view-crossref |
["Automatic Info" reftex-toggle-auto-view-crossref |
2456 |
:style toggle :selected reftex-auto-view-crossref-timer] |
:style toggle :selected reftex-auto-view-crossref-timer] |
2465 |
("Reference Style" |
("Reference Style" |
2466 |
["Default" (setq reftex-vref-is-default nil |
["Default" (setq reftex-vref-is-default nil |
2467 |
reftex-fref-is-default nil) |
reftex-fref-is-default nil) |
2468 |
:style radio :selected (not (or reftex-vref-is-default |
:style radio :selected (not (or reftex-vref-is-default |
2469 |
reftex-fref-is-default))] |
reftex-fref-is-default))] |
2470 |
["Varioref" (setq reftex-vref-is-default t |
["Varioref" (setq reftex-vref-is-default t |
2471 |
reftex-fref-is-default nil) |
reftex-fref-is-default nil) |
2500 |
(list 'reftex-add-index-macros (list 'list (list 'quote (car x)))) |
(list 'reftex-add-index-macros (list 'list (list 'quote (car x)))) |
2501 |
:style 'radio :selected |
:style 'radio :selected |
2502 |
(list 'memq (list 'quote (car x)) |
(list 'memq (list 'quote (car x)) |
2503 |
(list 'get 'reftex-docstruct-symbol |
(list 'get 'reftex-docstruct-symbol |
2504 |
(list 'quote 'reftex-index-macros-style))))) |
(list 'quote 'reftex-index-macros-style))))) |
2505 |
reftex-index-macros-builtin)) |
reftex-index-macros-builtin)) |
2506 |
"--" |
"--" |
2507 |
|
["Reset RefTeX Mode" reftex-reset-mode t] |
2508 |
|
"--" |
2509 |
("Customize" |
("Customize" |
2510 |
["Browse RefTeX Group" reftex-customize t] |
["Browse RefTeX Group" reftex-customize t] |
2511 |
"--" |
"--" |
2512 |
["Build Full Customize Menu" reftex-create-customize-menu |
["Build Full Customize Menu" reftex-create-customize-menu |
2513 |
(fboundp 'customize-menu-create)]) |
(fboundp 'customize-menu-create)]) |
2514 |
("Documentation" |
("Documentation" |
2515 |
["Info" reftex-info t] |
["Info" reftex-info t] |
2525 |
(interactive) |
(interactive) |
2526 |
(if (fboundp 'customize-menu-create) |
(if (fboundp 'customize-menu-create) |
2527 |
(progn |
(progn |
2528 |
(easy-menu-change |
(easy-menu-change |
2529 |
'("Ref") "Customize" |
'("Ref") "Customize" |
2530 |
`(["Browse RefTeX group" reftex-customize t] |
`(["Browse RefTeX group" reftex-customize t] |
2531 |
"--" |
"--" |
2563 |
;;; That's it! ---------------------------------------------------------------- |
;;; That's it! ---------------------------------------------------------------- |
2564 |
|
|
2565 |
(setq reftex-tables-dirty t) ; in case this file is evaluated by hand |
(setq reftex-tables-dirty t) ; in case this file is evaluated by hand |
2566 |
(provide 'reftex) |
(provide 'reftex) |
2567 |
|
|
2568 |
;;;============================================================================ |
;;;============================================================================ |
2569 |
|
|