Auto-commit of loaddefs files.
[emacs.git] / lisp / textmodes / reftex.el
blob160d9fb4cdf1f776c7aa44a955177a66ffd9268f
1 ;;; reftex.el --- minor mode for doing \label, \ref, \cite, \index in LaTeX
2 ;; Copyright (C) 1997-2000, 2003-2015 Free Software Foundation, Inc.
4 ;; Author: Carsten Dominik <dominik@science.uva.nl>
5 ;; Maintainer: auctex-devel@gnu.org
6 ;; Keywords: tex
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23 ;;; Commentary:
25 ;; RefTeX is a minor mode with distinct support for \ref, \label, \cite,
26 ;; and \index commands in (multi-file) LaTeX documents.
27 ;; - A table of contents provides easy access to any part of a document.
28 ;; - Labels are created semi-automatically.
29 ;; - Definition context of labels is provided when creating a reference.
30 ;; - Citations are simplified with efficient database lookup.
31 ;; - Text phrases can be collected in a file, for later global indexing.
32 ;; - The index preview buffer helps to check and edit index entries.
34 ;; There is an extensive Texinfo document describing RefTeX in detail.
35 ;; One way to view this documentation is `M-x reftex-info RET'.
37 ;; The documentation in various formats is also available at
39 ;; http://www.gnu.org/software/auctex/manual/reftex.index.html
41 ;; RefTeX is bundled with Emacs and available as a plug-in package for
42 ;; XEmacs 21.x. If you need to install it yourself, you can find a
43 ;; distribution at
45 ;; http://www.gnu.org/software/auctex/reftex.html
47 ;; RefTeX was written by Carsten Dominik <dominik@science.uva.nl> with
48 ;; contributions from Stephen Eglen. It is currently maintained by
49 ;; the AUCTeX project.
51 ;;; Code:
53 (eval-when-compile (require 'cl))
55 ;; Stuff that needs to be there when we use defcustom
56 (require 'custom)
58 (require 'easymenu)
60 (defvar reftex-tables-dirty t
61 "Flag showing if tables need to be re-computed.")
63 (eval-and-compile
64 (defun reftex-set-dirty (symbol value)
65 (setq reftex-tables-dirty t)
66 (set symbol value)))
69 ;; Configuration variables
70 (require 'reftex-vars)
73 ;;; Autoloads - see end for automatic autoloads
75 ;; We autoload tons of functions from these files, but some have
76 ;; a single function that needs to be globally autoloaded.
77 ;; The alternative is to use a Makefile rule + distinct autoload
78 ;; cookie (eg ;;;###reftex-autoload) for internal autoloads,
79 ;; as eg calendar/ does. But that seemed like overkill for 4 functions.
81 ;;;###autoload(autoload 'reftex-citation "reftex-cite" nil t)
82 ;;;###autoload(autoload 'reftex-all-document-files "reftex-parse")
83 ;;;###autoload(autoload 'reftex-isearch-minor-mode "reftex-global" nil t)
84 ;;;###autoload(autoload 'reftex-index-phrases-mode "reftex-index" nil t)
86 ;; Generated functions.
87 (autoload 'reftex-varioref-vref "reftex-ref"
88 "Make a varioref reference." t)
89 (autoload 'reftex-fancyref-fref "reftex-ref"
90 "Make a fancyref \\fref reference." t)
91 (autoload 'reftex-fancyref-Fref "reftex-ref"
92 "Make a fancyref \\Fref reference." t)
94 ;;; =========================================================================
95 ;;;
96 ;;; Define the formal stuff for a minor mode named RefTeX.
97 ;;;
99 (defconst reftex-version emacs-version
100 "Version string for RefTeX.")
102 (defvar reftex-mode-map (make-sparse-keymap)
103 "Keymap for RefTeX mode.")
105 (defvar reftex-mode-menu nil)
106 (defvar reftex-syntax-table nil)
107 (defvar reftex-syntax-table-for-bib nil)
109 (unless reftex-syntax-table
110 (setq reftex-syntax-table (copy-syntax-table))
111 (modify-syntax-entry ?\( "." reftex-syntax-table)
112 (modify-syntax-entry ?\) "." reftex-syntax-table))
114 (unless reftex-syntax-table-for-bib
115 (setq reftex-syntax-table-for-bib (copy-syntax-table))
116 (modify-syntax-entry ?\' "." reftex-syntax-table-for-bib)
117 (modify-syntax-entry ?\" "." reftex-syntax-table-for-bib)
118 (modify-syntax-entry ?\[ "." reftex-syntax-table-for-bib)
119 (modify-syntax-entry ?\] "." reftex-syntax-table-for-bib))
121 ;; The following definitions are out of place, but I need them here
122 ;; to make the compilation of reftex-mode not complain.
123 (defvar reftex-auto-view-crossref-timer nil
124 "The timer used for auto-view-crossref.")
125 (defvar reftex-toc-auto-recenter-timer nil
126 "The idle timer used to recenter the toc window.")
128 ;;;###autoload
129 (defun turn-on-reftex ()
130 "Turn on RefTeX mode."
131 (reftex-mode t))
133 (put 'reftex-mode :included '(memq major-mode '(latex-mode tex-mode)))
134 (put 'reftex-mode :menu-tag "RefTeX Mode")
135 ;;;###autoload
136 (define-minor-mode reftex-mode
137 "Minor mode with distinct support for \\label, \\ref and \\cite in LaTeX.
139 \\<reftex-mode-map>A Table of Contents of the entire (multifile) document with browsing
140 capabilities is available with `\\[reftex-toc]'.
142 Labels can be created with `\\[reftex-label]' and referenced with `\\[reftex-reference]'.
143 When referencing, you get a menu with all labels of a given type and
144 context of the label definition. The selected label is inserted as a
145 \\ref macro.
147 Citations can be made with `\\[reftex-citation]' which will use a regular expression
148 to pull out a *formatted* list of articles from your BibTeX
149 database. The selected citation is inserted as a \\cite macro.
151 Index entries can be made with `\\[reftex-index-selection-or-word]' which indexes the word at point
152 or the current selection. More general index entries are created with
153 `\\[reftex-index]'. `\\[reftex-display-index]' displays the compiled index.
155 Most command have help available on the fly. This help is accessed by
156 pressing `?' to any prompt mentioning this feature.
158 Extensive documentation about RefTeX is available in Info format.
159 You can view this information with `\\[reftex-info]'.
161 \\{reftex-mode-map}
162 Under X, these and other functions will also be available as `Ref' menu
163 on the menu bar.
165 ------------------------------------------------------------------------------"
166 :lighter " Ref" :keymap reftex-mode-map
167 (if reftex-mode
168 (progn
169 ;; Mode was turned on
170 (easy-menu-add reftex-mode-menu)
171 (and reftex-plug-into-AUCTeX
172 (reftex-plug-into-AUCTeX))
173 (unless (get 'reftex-auto-view-crossref 'initialized)
174 (and reftex-auto-view-crossref
175 (reftex-toggle-auto-view-crossref))
176 (put 'reftex-auto-view-crossref 'initialized t))
177 (unless (get 'reftex-auto-recenter-toc 'initialized)
178 (and (eq reftex-auto-recenter-toc t)
179 (reftex-toggle-auto-toc-recenter))
180 (put 'reftex-auto-recenter-toc 'initialized t))
182 ;; Prepare the special syntax tables.
183 (setq reftex-syntax-table (copy-syntax-table (syntax-table)))
184 (modify-syntax-entry ?\( "." reftex-syntax-table)
185 (modify-syntax-entry ?\) "." reftex-syntax-table)
187 (setq reftex-syntax-table-for-bib (copy-syntax-table))
188 (modify-syntax-entry ?\' "." reftex-syntax-table-for-bib)
189 (modify-syntax-entry ?\" "." reftex-syntax-table-for-bib)
190 (modify-syntax-entry ?\[ "." reftex-syntax-table-for-bib)
191 (modify-syntax-entry ?\] "." reftex-syntax-table-for-bib)
193 (run-hooks 'reftex-mode-hook))
194 ;; Mode was turned off
195 (easy-menu-remove reftex-mode-menu)))
197 (defvar reftex-docstruct-symbol)
198 (defun reftex-kill-buffer-hook ()
199 "Save RefTeX's parse file for this buffer if the information has changed."
200 ;; Save the parsing information if it was modified.
201 ;; This function should be installed in `kill-buffer-hook'.
202 ;; We are careful to make sure nothing goes wrong in this function.
203 (when (and (boundp 'reftex-mode) reftex-mode
204 (boundp 'reftex-save-parse-info) reftex-save-parse-info
205 (boundp 'reftex-docstruct-symbol) reftex-docstruct-symbol
206 (symbol-value reftex-docstruct-symbol)
207 (get reftex-docstruct-symbol 'modified))
208 ;; Write the file.
209 (condition-case nil
210 (reftex-access-parse-file 'write)
211 (error nil))))
213 (defun reftex-kill-emacs-hook ()
214 "Call `reftex-kill-buffer-hook' on all buffers."
215 ;; This function should be installed in `kill-emacs-hook'.
216 (save-excursion
217 (mapcar (lambda (buf)
218 (set-buffer buf)
219 (reftex-kill-buffer-hook))
220 (buffer-list))))
222 ;;; =========================================================================
224 ;;; Silence warnings about variables in other packages.
225 (defvar TeX-master)
226 (defvar LaTeX-section-hook)
227 (defvar LaTeX-label-function)
228 (defvar tex-main-file)
229 (defvar outline-minor-mode)
230 (defvar font-lock-mode)
231 (defvar font-lock-keywords)
232 (defvar font-lock-fontify-region-function)
234 ;;; =========================================================================
236 ;;; Multibuffer Variables
238 ;; Technical notes: These work as follows: We keep just one list
239 ;; of labels for each master file - this can save a lot of memory.
240 ;; `reftex-master-index-list' is an alist which connects the true file name
241 ;; of each master file with the symbols holding the information on that
242 ;; document. Each buffer has local variables which point to these symbols.
244 ;; List of variables which handle the multifile stuff.
245 ;; This list is used to tie, untie, and reset these symbols.
246 (defconst reftex-multifile-symbols
247 '(reftex-docstruct-symbol))
249 ;; Alist connecting master file names with the corresponding lisp symbols.
250 (defvar reftex-master-index-list nil)
252 ;; Last index used for a master file.
253 (defvar reftex-multifile-index 0)
255 ;; Variable holding the symbol with the label list of the document.
256 (defvar reftex-docstruct-symbol nil)
257 (make-variable-buffer-local 'reftex-docstruct-symbol)
259 (defun reftex-next-multifile-index ()
260 ;; Return the next free index for multifile symbols.
261 (incf reftex-multifile-index))
263 (defun reftex-tie-multifile-symbols ()
264 "Tie the buffer-local symbols to globals connected with the master file.
265 If the symbols for the current master file do not exist, they are created."
266 (let* ((master (file-truename (reftex-TeX-master-file)))
267 (index (assoc master reftex-master-index-list))
268 (symlist reftex-multifile-symbols)
269 symbol symname newflag)
270 ;; Find the correct index.
271 (if index
272 ;; Symbols do exist
273 (setq index (cdr index))
274 ;; Get a new index and add info to the alist.
275 (setq index (reftex-next-multifile-index)
276 newflag t)
277 (push (cons master index) reftex-master-index-list))
279 ;; Get/create symbols and tie them.
280 (while symlist
281 (setq symbol (car symlist)
282 symlist (cdr symlist)
283 symname (symbol-name symbol))
284 (set symbol (intern (concat symname "-" (int-to-string index))))
285 (put (symbol-value symbol) :master-index index)
286 ;; Initialize if new symbols.
287 (when newflag
288 (set (symbol-value symbol) nil)
289 (put (symbol-value symbol) 'reftex-index-macros-style '(default))
290 (put (symbol-value symbol) 'reftex-ref-style-list
291 reftex-ref-style-default-list)))
293 ;; Return t if the symbols did already exist, nil when we've made them.
294 (not newflag)))
296 (defun reftex-untie-multifile-symbols ()
297 "Remove ties from multifile symbols, so that next use makes new ones."
298 (let ((symlist reftex-multifile-symbols)
299 (symbol nil))
300 (while symlist
301 (setq symbol (car symlist)
302 symlist (cdr symlist))
303 (set symbol nil))))
305 (defun reftex-TeX-master-file ()
306 ;; Return the name of the master file associated with the current buffer.
307 ;; When AUCTeX is loaded, we will use it's more sophisticated method.
308 ;; We also support the default TeX and LaTeX modes by checking for a
309 ;; variable tex-main-file.
310 (let
311 ((master
312 (cond
313 ((fboundp 'TeX-master-file) ; AUCTeX is loaded. Use its mechanism.
314 (condition-case nil
315 (TeX-master-file t)
316 (error (buffer-file-name))))
317 ((fboundp 'tex-main-file) (tex-main-file)) ; Emacs LaTeX mode
318 ((boundp 'TeX-master) ; The variable is defined - let's use it.
319 (cond
320 ((eq TeX-master t)
321 (buffer-file-name))
322 ((eq TeX-master 'shared)
323 (setq TeX-master (read-file-name "Master file: "
324 nil nil t nil)))
325 (TeX-master)
327 (setq TeX-master (read-file-name "Master file: "
328 nil nil t nil)))))
329 ((boundp 'tex-main-file)
330 ;; This is the variable from the default TeX modes.
331 (cond
332 ((stringp tex-main-file)
333 ;; ok, this must be it
334 tex-main-file)
336 ;; In this case, the buffer is its own master.
337 (buffer-file-name))))
339 ;; Know nothing about master file. Assume this is a master file.
340 (buffer-file-name)))))
341 (cond
342 ((null master)
343 (error "Need a filename for this buffer, please save it first"))
344 ((or (file-exists-p (concat master ".tex"))
345 (reftex-get-buffer-visiting (concat master ".tex")))
346 ;; Ahh, an extra .tex was missing...
347 (setq master (concat master ".tex")))
348 ((or (file-exists-p master)
349 (reftex-get-buffer-visiting master))
350 ;; We either see the file, or have a buffer on it. OK.
353 ;; Use buffer file name.
354 (setq master (buffer-file-name))))
355 (expand-file-name master)))
357 (defun reftex-is-multi ()
358 ;; Tell if this is a multifile document. When not sure, say yes.
359 (let ((entry (assq 'is-multi (symbol-value reftex-docstruct-symbol))))
360 (if entry
361 (nth 1 entry)
362 t)))
364 (defun reftex-set-cite-format (value)
365 "Set the document-local value of `reftex-cite-format'.
366 When such a value exists, it overwrites the setting given with
367 `reftex-cite-format'. See the documentation of `reftex-cite-format'
368 for possible values. This function should be used from AUCTeX style files."
369 (unless reftex-docstruct-symbol
370 (reftex-tie-multifile-symbols))
371 (when (and reftex-docstruct-symbol
372 (symbolp reftex-docstruct-symbol))
373 (put reftex-docstruct-symbol 'reftex-cite-format value)))
375 (defun reftex-get-cite-format ()
376 ;; Return the current citation format. Either the document-local value in
377 ;; reftex-cite-format-symbol, or the global value in reftex-cite-format.
378 (if (and reftex-docstruct-symbol
379 (symbolp reftex-docstruct-symbol)
380 (get reftex-docstruct-symbol 'reftex-cite-format))
381 (get reftex-docstruct-symbol 'reftex-cite-format)
382 reftex-cite-format))
384 (defun reftex-add-index-macros (entry-list)
385 "Add index macro descriptions to `reftex-index-macros-style'.
386 The format of ENTRY-LIST is exactly like `reftex-index-macros'. See there
387 for details.
388 This function makes it possible to support RefTeX from AUCTeX style files.
389 The entries in ENTRY-LIST will be processed after the user settings in
390 `reftex-index-entries', and before the defaults. Any changes made to
391 `reftex-index-macros-style' will raise a flag to the effect that
392 the label information is recompiled on next use."
393 (unless reftex-docstruct-symbol
394 (reftex-tie-multifile-symbols))
395 (when (and reftex-docstruct-symbol
396 (symbolp reftex-docstruct-symbol))
397 (let ((list (get reftex-docstruct-symbol 'reftex-index-macros-style))
398 entry changed)
399 (while entry-list
400 (setq entry (pop entry-list))
401 ;; When it is a symbol, remove all other symbols
402 (and (symbolp entry)
403 (not (memq entry list))
404 (setq list (reftex-remove-symbols-from-list list)))
405 ;; Add to list unless already member
406 (unless (member entry list)
407 (setq reftex-tables-dirty t
408 changed t)
409 (push entry list)))
410 (when changed
411 (put reftex-docstruct-symbol 'reftex-index-macros-style list)))))
413 (defun reftex-ref-style-activate (style)
414 "Activate the referencing style STYLE."
415 (reftex-ref-style-toggle style 'activate))
417 (defun reftex-ref-style-toggle (style &optional action)
418 "Activate or deactivate the referencing style STYLE.
419 With the optional argument ACTION a certain action can be forced.
420 The symbol `activate' will activate the style and `deactivate'
421 will deactivate it."
422 (unless reftex-docstruct-symbol
423 (reftex-tie-multifile-symbols))
424 (when (and reftex-docstruct-symbol
425 (symbolp reftex-docstruct-symbol))
426 (let ((list (get reftex-docstruct-symbol 'reftex-ref-style-list))
427 changed)
428 (cond ((eq action 'activate)
429 (unless (member style list)
430 (setq reftex-tables-dirty t
431 changed t)
432 (add-to-list 'list style t)))
433 ((eq action 'deactivate)
434 (when (member style list)
435 (setq reftex-tables-dirty t
436 changed t)
437 (setq list (delete style list))))
439 (if (member style list)
440 (delete style list)
441 (add-to-list 'list style t))
442 (setq reftex-tables-dirty t
443 changed t)))
444 (when changed
445 (put reftex-docstruct-symbol 'reftex-ref-style-list list)))))
447 (defun reftex-ref-style-list ()
448 "Return the list of referencing styles to be active at the moment."
449 ;; Initialize the value of `reftex-ref-style-list' and tie it to the
450 ;; docstruct symbol if necessary.
451 (unless reftex-docstruct-symbol
452 (reftex-tie-multifile-symbols))
453 (if (and reftex-docstruct-symbol
454 (symbolp reftex-docstruct-symbol)
455 (get reftex-docstruct-symbol 'reftex-ref-style-list))
456 (get reftex-docstruct-symbol 'reftex-ref-style-list)
457 reftex-ref-style-default-list))
459 ;;; =========================================================================
461 ;;; Functions to compile the tables, reset the mode etc.
463 ;; The following constants are derived from `reftex-label-alist'.
465 ;; Prompt used for label type queries directed to the user.
466 (defvar reftex-type-query-prompt nil)
468 ;; Help string for label type queries.
469 (defvar reftex-type-query-help nil)
471 ;; Alist relating label type to reference format.
472 (defvar reftex-typekey-to-format-alist nil)
474 ;; Alist relating label type to label prefix.
475 (defvar reftex-typekey-to-prefix-alist nil)
477 ;; Alist relating environments or macros to label type and context regexp.
478 (defvar reftex-env-or-mac-alist nil)
480 ;; List of special environment parser functions
481 (defvar reftex-special-env-parsers nil)
483 ;; List of macros carrying a label.
484 (defvar reftex-label-mac-list nil)
486 ;; List of environments carrying a label.
487 (defvar reftex-label-env-list nil)
489 ;; List of all typekey letters in use.
490 (defvar reftex-typekey-list nil)
492 ;; Alist relating magic words to a label type.
493 (defvar reftex-words-to-typekey-alist nil)
494 ;; Alist relating label prefixes to a label type.
495 (defvar reftex-prefix-to-typekey-alist nil)
497 ;; The last list-of-labels entry used in a reference.
498 (defvar reftex-last-used-reference (list nil nil nil nil))
500 ;; Alist relating index macros to other info.
501 (defvar reftex-key-to-index-macro-alist nil)
502 ;; Prompt for index macro queries
503 (defvar reftex-query-index-macro-prompt nil)
504 ;; Help string for index macro queries
505 (defvar reftex-query-index-macro-help nil)
507 ;; The message when follow-mode is suspended
508 (defvar reftex-no-follow-message
509 "No follow-mode into unvisited file. Press SPC to visit it.")
510 (defvar reftex-no-info-message
511 "%s: info not available, use `\\[reftex-view-crossref]' to get it.")
513 ;; Global variables used for communication between functions.
514 (defvar reftex-default-context-position nil)
515 (defvar reftex-location-start nil)
516 (defvar reftex-call-back-to-this-buffer nil)
517 (defvar reftex-select-return-marker (make-marker))
518 (defvar reftex-active-toc nil)
519 (defvar reftex-tex-path nil)
520 (defvar reftex-bib-path nil)
521 (defvar reftex-select-marked nil)
522 (defvar reftex-last-follow-point nil)
523 (defvar reftex-latex-syntax-table nil)
524 (defvar reftex-prefix nil)
525 (defvar reftex-section-levels-all nil)
526 (defvar reftex-buffers-with-changed-invisibility nil)
527 (defvar reftex-callback-fwd t)
528 (defvar reftex-last-toc-master nil
529 "Stores the name of the tex file that `reftex-toc' was last run on.")
530 ;; Marker for return point from recursive edit
531 (defvar reftex-recursive-edit-marker (make-marker))
533 ;; List of buffers created temporarily for lookup, which should be killed.
534 (defvar reftex-buffers-to-kill nil)
536 ;; Regexp to find anything.
537 (defvar reftex-section-regexp nil)
538 (defvar reftex-section-or-include-regexp nil)
539 (defvar reftex-index-macro-regexp nil)
540 (defvar reftex-index-level-re nil)
541 (defvar reftex-index-key-end-re nil)
542 (defvar reftex-find-index-entry-regexp-format nil)
543 (defvar reftex-everything-regexp nil)
544 (defvar reftex-everything-regexp-no-index nil)
545 (defvar reftex-index-re nil)
546 (defvar reftex-find-citation-regexp-format
547 "\\\\\\([a-zA-Z]*cite[*a-zA-Z]*\\*?\\|bibentry\\)\\(\\[[^]]*\\]\\|{[^}]*}\\)*{\\([^}]*,\\)?\\(%s\\)[},]")
548 (defvar reftex-find-reference-format
549 "\\\\\\(ref[a-zA-Z]*\\|[a-zA-Z]*ref\\(range\\)?\\)\\*?\\(\\[[^]]*\\]\\|{[^}]*}\\)*{\\(%s\\)}")
550 (defvar reftex-macros-with-labels nil)
551 (defvar reftex-macros-with-index nil)
552 (defvar reftex-index-macro-alist nil)
553 (defvar reftex-find-label-regexp-format nil)
554 (defvar reftex-find-label-regexp-format2 nil)
556 ;; Constants for making RefTeX open to Texinfo hooking
557 (defvar reftex-section-pre-regexp "\\\\")
558 ;; Including `\' as a character to be matched at the end of the regexp
559 ;; will allow stuff like \begin{foo}\label{bar} to be matched. This
560 ;; will make the parser to advance one char too much. Therefore
561 ;; `reftex-parse-from-file' will step one char back if a section is
562 ;; found.
563 (defvar reftex-section-post-regexp "\\*?\\(\\[[^]]*\\]\\)?[[{ \t\r\n\\]")
564 (defvar reftex-section-info-function 'reftex-section-info)
566 (defvar reftex-memory nil
567 "Memorizes old variable values to indicate changes in these variables.")
569 ;; A list of all variables in the cache.
570 ;; The cache is used to save the compiled versions of some variables.
571 (defconst reftex-cache-variables
572 '(reftex-memory ;; This MUST ALWAYS be the first!
574 ;; Outline
575 reftex-section-levels-all
577 ;; Labels
578 reftex-env-or-mac-alist
579 reftex-special-env-parsers
580 reftex-macros-with-labels
581 reftex-label-mac-list
582 reftex-label-env-list
583 reftex-typekey-list
584 reftex-typekey-to-format-alist
585 reftex-typekey-to-prefix-alist
586 reftex-words-to-typekey-alist
587 reftex-prefix-to-typekey-alist
588 reftex-type-query-prompt
589 reftex-type-query-help
591 ;; Index
592 reftex-index-macro-alist
593 reftex-macros-with-index
594 reftex-query-index-macro-prompt
595 reftex-query-index-macro-help
596 reftex-key-to-index-macro-alist
598 ;; Regular expressions
599 reftex-section-regexp
600 reftex-section-or-include-regexp
601 reftex-index-re
602 reftex-everything-regexp
603 reftex-everything-regexp-no-index
604 reftex-find-label-regexp-format
605 reftex-find-label-regexp-format2
606 reftex-find-index-entry-regexp-format
609 (defun reftex-ensure-compiled-variables ()
610 ;; Recompile the label alist when necessary
611 (let* ((mem reftex-memory)
612 (cache (get reftex-docstruct-symbol 'reftex-cache))
613 (cmem (car cache))
614 (alist reftex-label-alist)
615 (levels (get reftex-docstruct-symbol 'reftex-section-levels))
616 (style (get reftex-docstruct-symbol 'reftex-label-alist-style))
617 (default reftex-default-label-alist-entries)
618 (index reftex-index-macros)
619 (istyle (get reftex-docstruct-symbol 'reftex-index-macros-style)))
620 (cond
621 (reftex-tables-dirty (reftex-compile-variables))
622 ((and (eq alist (nth 0 mem))
623 (eq levels (nth 1 mem))
624 (eq style (nth 2 mem))
625 (eq default (nth 3 mem))
626 (eq index (nth 4 mem))
627 (eq istyle (nth 5 mem)))) ;; everything is OK
628 ((and (eq alist (nth 0 cmem))
629 (eq levels (nth 1 cmem))
630 (eq style (nth 2 cmem))
631 (eq default (nth 2 cmem))
632 (eq index (nth 4 cmem))
633 (eq istyle (nth 5 cmem)))
634 ;; restore the cache
635 (message "Restoring cache")
636 (mapcar (lambda (sym) (set sym (pop cache))) reftex-cache-variables))
637 (t (reftex-compile-variables)))))
639 (defun reftex-reset-mode ()
640 "Reset RefTeX Mode.
641 This will re-compile the configuration information and remove all
642 current scanning information and the parse file to enforce a rescan
643 on next use."
644 (interactive)
646 ;; Reset the file search path variables
647 (loop for prop in '(status master-dir recursive-path rec-type) do
648 (put 'reftex-tex-path prop nil)
649 (put 'reftex-bib-path prop nil))
651 ;; Kill temporary buffers associated with RefTeX - just in case they
652 ;; were not cleaned up properly
653 (save-excursion
654 (let ((buffer-list '("*RefTeX Help*" "*RefTeX Select*"
655 "*Duplicate Labels*" "*toc*" " *RefTeX-scratch*"))
656 buf)
657 (while (setq buf (pop buffer-list))
658 (if (get-buffer buf)
659 (kill-buffer buf))))
660 (reftex-erase-all-selection-and-index-buffers))
662 ;; Make sure the current document will be rescanned soon.
663 (reftex-reset-scanning-information)
665 ;; Remove any parse info file
666 (reftex-access-parse-file 'kill)
668 ;; Plug functions into AUCTeX if the user option says so.
669 (and reftex-plug-into-AUCTeX
670 (reftex-plug-into-AUCTeX))
672 (reftex-compile-variables))
674 ;;;###autoload
675 (defun reftex-reset-scanning-information ()
676 "Reset the symbols containing information from buffer scanning.
677 This enforces rescanning the buffer on next use."
678 (if (string= reftex-last-toc-master (reftex-TeX-master-file))
679 (reftex-erase-buffer "*toc*"))
680 (let ((symlist reftex-multifile-symbols)
681 symbol)
682 (while symlist
683 (setq symbol (car symlist)
684 symlist (cdr symlist))
685 (if (and (symbolp (symbol-value symbol))
686 (not (null (symbol-value symbol))))
687 (set (symbol-value symbol) nil)))))
689 (defun reftex-erase-all-selection-and-index-buffers ()
690 ;; Remove all selection buffers associated with current document.
691 (mapc
692 (lambda (type)
693 (reftex-erase-buffer (reftex-make-selection-buffer-name type)))
694 reftex-typekey-list)
695 ;; Kill all index buffers
696 (mapc
697 (lambda (tag)
698 (reftex-kill-buffer (reftex-make-index-buffer-name tag)))
699 (cdr (assoc 'index-tags (symbol-value reftex-docstruct-symbol)))))
701 (defun reftex-compile-variables ()
702 ;; Compile the information in reftex-label-alist & Co.
704 (message "Compiling label environment definitions...")
706 ;; Update AUCTeX style information
707 (when (and (featurep 'tex-site) (fboundp 'TeX-update-style))
708 (condition-case nil (TeX-update-style) (error nil)))
710 ;; Record that we have done this, and what we have used.
711 (setq reftex-tables-dirty nil)
712 (setq reftex-memory
713 (list reftex-label-alist
714 (get reftex-docstruct-symbol 'reftex-section-levels)
715 (get reftex-docstruct-symbol 'reftex-label-alist-style)
716 reftex-default-label-alist-entries
717 reftex-index-macros
718 (get reftex-docstruct-symbol 'reftex-index-macros-style)))
720 ;; Compile information in reftex-label-alist
721 (let ((all (reftex-uniquify-by-car
722 (reftex-splice-symbols-into-list
723 (append reftex-label-alist
724 (get reftex-docstruct-symbol
725 'reftex-label-alist-style)
726 reftex-default-label-alist-entries)
727 reftex-label-alist-builtin)
728 '(nil)))
729 (all-index (reftex-uniquify-by-car
730 (reftex-splice-symbols-into-list
731 (append reftex-index-macros
732 (get reftex-docstruct-symbol
733 'reftex-index-macros-style)
734 '(default))
735 reftex-index-macros-builtin)))
736 entry env-or-mac typekeychar typekey prefix context word
737 fmt reffmt labelfmt wordlist qh-list macros-with-labels
738 nargs nlabel opt-args cell sum i
739 macro verify repeat nindex tag key toc-level toc-levels)
741 (setq reftex-words-to-typekey-alist nil
742 reftex-prefix-to-typekey-alist
743 '(("sec:" . "s") ("cha:" . "s") ("chap:" . "s"))
744 reftex-typekey-list nil
745 reftex-typekey-to-format-alist nil
746 reftex-typekey-to-prefix-alist nil
747 reftex-env-or-mac-alist nil
748 reftex-label-env-list nil
749 reftex-label-mac-list nil)
750 (while all
751 (catch 'next-entry
752 (setq entry (car all)
753 env-or-mac (car entry)
754 entry (cdr entry)
755 all (cdr all))
756 (if (null env-or-mac)
757 (setq env-or-mac ""))
758 (if (stringp (car entry))
759 ;; This is before version 2.00 - convert entry to new format
760 ;; This is just to keep old users happy
761 (setq entry (cons (string-to-char (car entry))
762 (cons (concat (car entry) ":")
763 (cdr entry)))))
764 (setq typekeychar (nth 0 entry)
765 typekey (if typekeychar (char-to-string typekeychar) nil)
766 prefix (nth 1 entry)
767 fmt (nth 2 entry)
768 context (nth 3 entry)
769 wordlist (nth 4 entry)
770 toc-level (nth 5 entry))
771 (if (stringp wordlist)
772 ;; This is before version 2.04 - convert to new format
773 (setq wordlist (nthcdr 4 entry)))
775 (if (and (stringp fmt)
776 (string-match "@" fmt))
777 ;; Special syntax for specifying a label format
778 (setq fmt (split-string fmt "@+"))
779 (setq fmt (list "\\label{%s}" fmt)))
780 (setq labelfmt (car fmt)
781 reffmt (nth 1 fmt))
782 ;; Note a new typekey
783 (if typekey
784 (add-to-list 'reftex-typekey-list typekey))
785 (if (and typekey prefix
786 (not (assoc prefix reftex-prefix-to-typekey-alist)))
787 (add-to-list 'reftex-prefix-to-typekey-alist
788 (cons prefix typekey)))
789 (if (and typekey prefix
790 (not (assoc typekey reftex-typekey-to-prefix-alist)))
791 (add-to-list 'reftex-typekey-to-prefix-alist
792 (cons typekey prefix)))
793 ;; Check if this is a macro or environment
794 (cond
795 ((symbolp env-or-mac)
796 ;; A special parser function
797 (unless (fboundp env-or-mac)
798 (message "Warning: %s does not seem to be a valid function"
799 env-or-mac))
800 (setq nargs nil nlabel nil opt-args nil)
801 (add-to-list 'reftex-special-env-parsers env-or-mac)
802 (setq env-or-mac (symbol-name env-or-mac)))
803 ((string-match "\\`\\\\" env-or-mac)
804 ;; It's a macro
805 (let ((result (reftex-parse-args env-or-mac)))
806 (setq env-or-mac (or (first result) env-or-mac)
807 nargs (second result)
808 nlabel (third result)
809 opt-args (fourth result))
810 (if nlabel (add-to-list 'macros-with-labels env-or-mac)))
811 (if typekey (add-to-list 'reftex-label-mac-list env-or-mac)))
813 ;; It's an environment
814 (setq nargs nil nlabel nil opt-args nil)
815 (cond ((string= env-or-mac "any"))
816 ((string= env-or-mac ""))
817 ((string= env-or-mac "section"))
819 (add-to-list 'reftex-label-env-list env-or-mac)
820 (if toc-level
821 (let ((string (format "begin{%s}" env-or-mac)))
822 (or (assoc string toc-levels)
823 (push (cons string toc-level) toc-levels))))))))
824 ;; Translate some special context cases
825 (when (assq context reftex-default-context-regexps)
826 (setq context
827 (format
828 (cdr (assq context reftex-default-context-regexps))
829 (regexp-quote env-or-mac))))
830 ;; See if this is the first format for this typekey
831 (and reffmt
832 (not (assoc typekey reftex-typekey-to-format-alist))
833 (push (cons typekey reffmt) reftex-typekey-to-format-alist))
834 ;; See if this is the first definition for this env-or-mac
835 (and (not (string= env-or-mac "any"))
836 (not (string= env-or-mac ""))
837 (not (assoc env-or-mac reftex-env-or-mac-alist))
838 (push (list env-or-mac typekey context labelfmt
839 nargs nlabel opt-args)
840 reftex-env-or-mac-alist))
841 ;; Are the magic words regular expressions? Quote normal words.
842 (if (eq (car wordlist) 'regexp)
843 (setq wordlist (cdr wordlist))
844 (setq wordlist (mapcar 'regexp-quote wordlist)))
845 ;; Remember the first association of each word.
846 (while (stringp (setq word (pop wordlist)))
847 (or (assoc word reftex-words-to-typekey-alist)
848 (push (cons word typekey) reftex-words-to-typekey-alist)))
849 (cond
850 ((string= "" env-or-mac) nil)
851 ((setq cell (assoc typekey qh-list))
852 (push env-or-mac (cdr cell)))
853 (typekey
854 (push (list typekey env-or-mac) qh-list)))))
856 (setq reftex-typekey-to-prefix-alist
857 (nreverse reftex-typekey-to-prefix-alist))
859 ;; Prepare the typekey query prompt and help string.
860 (setq qh-list
861 (sort qh-list
862 (lambda (x1 x2)
863 (string< (downcase (car x1)) (downcase (car x2))))))
864 (setq reftex-type-query-prompt
865 (concat "Label type: ["
866 (mapconcat (lambda(x) (format "%s" (car x)))
867 qh-list "")
868 "]"))
869 ;; In the help string, we need to wrap lines...
870 (setq reftex-type-query-help
871 (concat
872 "SELECT A LABEL TYPE:\n--------------------\n"
873 (mapconcat
874 (lambda(x)
875 (setq sum 0)
876 (format " [%s] %s"
877 (car x)
878 (mapconcat (lambda(env)
879 (setq sum (+ sum (length env)))
880 (if (< sum 60)
882 (setq sum 0)
883 (concat "\n " env)))
884 (cdr x) " ")))
885 qh-list "\n")))
887 ;; Convert magic words to regular expressions. We make regular expressions
888 ;; which allow for some chars from the ref format to be in the buffer.
889 ;; These characters will be seen and removed.
890 (setq reftex-words-to-typekey-alist
891 (mapcar
892 (lambda (x)
893 (setq word (car x)
894 typekey (cdr x)
895 fmt (cdr (assoc typekey reftex-typekey-to-format-alist)))
896 (setq word (concat "\\W\\(" word "[ \t\n\r]*\\)\\("))
897 (setq i 0)
898 (while (and (< i 10) ; maximum number of format chars allowed
899 (< i (length fmt))
900 (not (member (aref fmt i) '(?%))))
901 (setq word (concat word "\\|" (regexp-quote
902 (substring fmt 0 (1+ i)))))
903 (incf i))
904 (cons (concat word "\\)\\=") typekey))
905 (nreverse reftex-words-to-typekey-alist)))
907 ;; Parse the index macros
908 (setq reftex-index-macro-alist nil
909 reftex-key-to-index-macro-alist nil
910 reftex-macros-with-index nil)
911 (while all-index
912 (setq entry (car all-index)
913 macro (car entry)
914 tag (nth 1 entry)
915 key (nth 2 entry)
916 prefix (or (nth 3 entry) "")
917 verify (nth 4 entry)
918 ;; For repeat, we need to be compatible with older code
919 ;; This information used to be given only for the default macro,
920 ;; but later we required to have it for *every* index macro
921 repeat (cond ((> (length entry) 5) (nth 5 entry))
922 ((and (eq key (car reftex-index-default-macro))
923 (> (length reftex-index-default-macro) 2))
924 ;; User has old setting - respect it
925 (nth 2 reftex-index-default-macro))
926 (t t))
927 all-index (cdr all-index))
928 (let ((result (reftex-parse-args macro)))
929 (setq macro (or (first result) macro)
930 nargs (second result)
931 nindex (third result)
932 opt-args (fourth result))
933 (unless (member macro reftex-macros-with-index)
934 ;; 0 1 2 3 4 5 6 7
935 (push (list macro tag prefix verify nargs nindex opt-args repeat)
936 reftex-index-macro-alist)
937 (or (assoc key reftex-key-to-index-macro-alist)
938 (push (list key macro) reftex-key-to-index-macro-alist))
939 (push macro reftex-macros-with-index))))
940 ;; Make the prompt and help string for index macros query
941 (setq reftex-key-to-index-macro-alist
942 (sort reftex-key-to-index-macro-alist
943 (lambda (a b) (< (downcase (car a)) (downcase (car b))))))
944 (setq reftex-query-index-macro-prompt
945 (concat "Index macro: ["
946 (mapconcat (lambda (x) (char-to-string (car x)))
947 reftex-key-to-index-macro-alist "")
948 "]"))
949 (setq i 0
950 reftex-query-index-macro-help
951 (concat
952 "SELECT A MACRO:\n---------------\n"
953 (mapconcat
954 (lambda(x)
955 (format "[%c] %-20.20s%s" (car x) (nth 1 x)
956 (if (= 0 (mod (incf i) 3)) "\n" "")))
957 reftex-key-to-index-macro-alist "")))
959 ;; Make the full list of section levels
960 (setq reftex-section-levels-all
961 (append toc-levels
962 (get reftex-docstruct-symbol 'reftex-section-levels)
963 reftex-section-levels))
965 ;; Calculate the regular expressions
966 (let* (
967 ; (wbol "\\(\\`\\|[\n\r]\\)[ \t]*")
968 (wbol "\\(^\\)[ \t]*") ; Need to keep the empty group because
969 ; match numbers are hard coded
970 (label-re (concat "\\(?:"
971 (mapconcat 'identity reftex-label-regexps "\\|")
972 "\\)"))
973 (include-re (concat wbol
974 "\\\\\\("
975 (mapconcat 'identity
976 reftex-include-file-commands "\\|")
977 "\\)[{ \t]+\\([^} \t\n\r]+\\)"))
978 (section-re
979 (concat wbol reftex-section-pre-regexp "\\("
980 (mapconcat (lambda (x) (regexp-quote (car x)))
981 reftex-section-levels-all "\\|")
982 "\\)" reftex-section-post-regexp))
983 (appendix-re (concat wbol "\\(\\\\appendix\\)"))
984 (macro-re
985 (if macros-with-labels
986 (concat "\\("
987 (mapconcat 'regexp-quote macros-with-labels "\\|")
988 "\\)[[{]")
989 ""))
990 (index-re
991 (concat "\\("
992 (mapconcat 'regexp-quote reftex-macros-with-index "\\|")
993 "\\)[[{]"))
994 (find-index-re-format
995 (concat "\\("
996 (mapconcat 'regexp-quote reftex-macros-with-index "\\|")
997 "\\)\\([[{][^]}]*[]}]\\)*[[{]\\(%s\\)[]}]"))
998 (find-label-re-format
999 (concat "\\("
1000 "label[[:space:]]*=[[:space:]]*"
1001 "\\|"
1002 (mapconcat 'regexp-quote (append '("\\label")
1003 macros-with-labels) "\\|")
1004 "\\)\\([[{][^]}]*[]}]\\)*[[{]\\(%s\\)[]}]"))
1005 (index-level-re
1006 (regexp-quote (nth 0 reftex-index-special-chars)))
1007 (index-key-end-re ;; ^]- not allowed
1008 (concat "[^" (nth 3 reftex-index-special-chars) "]"
1009 "[" (nth 1 reftex-index-special-chars)
1010 (nth 2 reftex-index-special-chars) "]"))
1012 (setq reftex-section-regexp section-re
1013 reftex-section-or-include-regexp
1014 (concat section-re "\\|" include-re)
1015 reftex-everything-regexp
1016 (concat label-re "\\|" section-re "\\|" include-re
1017 "\\|" appendix-re
1018 "\\|" index-re
1019 (if macros-with-labels "\\|" "") macro-re)
1020 reftex-everything-regexp-no-index
1021 (concat label-re "\\|" section-re "\\|" include-re
1022 "\\|" appendix-re
1023 "\\|" "\\(\\\\6\\\\3\\\\1\\)" ; This is unlikely to match
1024 (if macros-with-labels "\\|" "") macro-re)
1025 reftex-index-re index-re
1026 reftex-index-level-re index-level-re
1027 reftex-index-key-end-re index-key-end-re
1028 reftex-macros-with-labels macros-with-labels
1029 reftex-find-index-entry-regexp-format find-index-re-format
1030 reftex-find-label-regexp-format find-label-re-format
1031 reftex-find-label-regexp-format2
1032 "\\([]} \t\n\r]\\)\\([[{]\\)\\(%s\\)[]}]")
1033 (message "Compiling label environment definitions...done")))
1034 (put reftex-docstruct-symbol 'reftex-cache
1035 (mapcar 'symbol-value reftex-cache-variables)))
1037 (defun reftex-parse-args (macro)
1038 ;; Return a list of macro name, nargs, arg-nr which is label and a list of
1039 ;; optional argument indices.
1040 (if (string-match "[[{]\\*?[]}]" macro)
1041 (progn
1042 (let ((must-match (substring macro 0 (match-beginning 0)))
1043 (args (substring macro (match-beginning 0)))
1044 opt-list nlabel (cnt 0))
1045 (while (string-match "\\`[[{]\\(\\*\\)?[]}]" args)
1046 (incf cnt)
1047 (when (eq ?\[ (string-to-char args))
1048 (push cnt opt-list))
1049 (when (and (match-end 1)
1050 (not nlabel))
1051 (setq nlabel cnt))
1052 (setq args (substring args (match-end 0))))
1053 (list must-match cnt nlabel opt-list)))
1054 nil))
1056 ;;; =========================================================================
1058 ;;; Accessing the parse information
1060 (defun reftex-access-scan-info (&optional rescan file)
1061 "Ensure access to the scanning info for the current file."
1062 ;; When the multifile symbols are not yet tied,
1063 ;; tie them. When they are empty or RESCAN is non-nil, scan the document.
1064 ;; But, when RESCAN is -1, don't rescan even if docstruct is empty.
1065 ;; When FILE is non-nil, parse only from that file.
1067 ;; Error out in a buffer without a file.
1068 (if (and reftex-mode
1069 (not (buffer-file-name)))
1070 (error "RefTeX works only in buffers visiting a file"))
1072 ;; Make sure we have the symbols tied
1073 (if (eq reftex-docstruct-symbol nil)
1074 ;; Symbols are not yet tied: Tie them.
1075 (reftex-tie-multifile-symbols))
1077 (reftex-ensure-compiled-variables)
1079 (when (or (null (symbol-value reftex-docstruct-symbol))
1080 (member rescan '(t 1 (4) (16))))
1081 ;; The docstruct will change: Remove selection buffers.
1082 (save-excursion
1083 (reftex-erase-buffer "*toc*")
1084 (reftex-erase-all-selection-and-index-buffers)))
1086 (if (and (null (symbol-value reftex-docstruct-symbol))
1087 (not (member rescan '(t 1 (4) (16))))
1088 reftex-save-parse-info)
1089 ;; Try to read the stuff from a file
1090 (reftex-access-parse-file 'read))
1092 (cond
1093 ((equal rescan -1)) ;; We are not allowed to scan.
1094 ((not (symbol-value reftex-docstruct-symbol))
1095 ;; Scan the whole document
1096 (reftex-do-parse 1 file))
1097 ((member rescan '(t 1 (4) (16)))
1098 ;; Scan whatever was required by the caller.
1099 (reftex-do-parse rescan file))))
1101 (defun reftex-scanning-info-available-p ()
1102 "Is the scanning info about the current document available?"
1103 (unless reftex-docstruct-symbol
1104 (reftex-tie-multifile-symbols))
1105 (and (symbolp reftex-docstruct-symbol)
1106 (symbol-value reftex-docstruct-symbol)
1109 (defun reftex-silence-toc-markers (list n)
1110 ;; Set all toc markers in the first N entries in list to nil
1111 (while (and list (> (decf n) -1))
1112 (and (eq (car (car list)) 'toc)
1113 (markerp (nth 4 (car list)))
1114 (set-marker (nth 4 (car list)) nil))
1115 (pop list)))
1117 (defun reftex-access-parse-file (action)
1118 "Perform ACTION on the parse file (the .rel file).
1119 Valid actions are: readable, restore, read, kill, write."
1120 (let* ((list (symbol-value reftex-docstruct-symbol))
1121 (docstruct-symbol reftex-docstruct-symbol)
1122 (master (reftex-TeX-master-file))
1123 (enable-local-variables nil)
1124 (file (if (string-match "\\.[a-zA-Z]+\\'" master)
1125 (concat (substring master 0 (match-beginning 0))
1126 reftex-parse-file-extension)
1127 (concat master reftex-parse-file-extension))))
1128 (cond
1129 ((eq action 'readable)
1130 (file-readable-p file))
1131 ((eq action 'restore)
1132 (put reftex-docstruct-symbol 'modified nil)
1133 (if (eq reftex-docstruct-symbol nil)
1134 ;; Symbols are not yet tied: Tie them.
1135 (reftex-tie-multifile-symbols))
1136 (if (file-exists-p file)
1137 ;; load the file and return t for success
1138 (condition-case nil
1139 (progn (load-file file) t)
1140 (error (set reftex-docstruct-symbol nil)
1141 (error "Error while loading file %s" file)))
1142 ;; Throw an exception if the file does not exist
1143 (error "No restore file %s" file)))
1144 ((eq action 'read)
1145 (put reftex-docstruct-symbol 'modified nil)
1146 (if (file-exists-p file)
1147 ;; load the file and return t for success
1148 (condition-case nil
1149 (progn
1150 (load-file file)
1151 (reftex-check-parse-consistency)
1153 (error (message "Error while restoring file %s" file)
1154 (set reftex-docstruct-symbol nil)
1155 nil))
1156 ;; return nil for failure, but no exception
1157 nil))
1158 ((eq action 'kill)
1159 ;; Remove the file
1160 (when (and (file-exists-p file) (file-writable-p file))
1161 (message "Unlinking file %s" file)
1162 (delete-file file)))
1164 (put docstruct-symbol 'modified nil)
1165 (save-excursion
1166 (if (file-writable-p file)
1167 (with-temp-file file
1168 (message "Writing parse file %s" (abbreviate-file-name file))
1169 (insert (format ";; RefTeX parse info file\n"))
1170 (insert (format ";; File: %s\n" master))
1171 (insert (format ";; User: %s (%s)\n\n"
1172 (user-login-name) (user-full-name)))
1173 (insert "(set reftex-docstruct-symbol '(\n\n")
1174 (let ((standard-output (current-buffer)))
1175 (mapc
1176 (lambda (x)
1177 (cond ((eq (car x) 'toc)
1178 ;; A toc entry. Do not save the marker.
1179 ;; Save the markers position at position 8
1180 (print (list 'toc "toc" (nth 2 x) (nth 3 x)
1181 nil (nth 5 x) (nth 6 x) (nth 7 x)
1182 (or (and (markerp (nth 4 x))
1183 (marker-position (nth 4 x)))
1184 (nth 8 x)))))
1185 ((and (not (eq t reftex-support-index))
1186 (eq (car x) 'index))
1187 ;; Don't save index entries
1189 (t (print x))))
1190 list))
1191 (insert "))\n\n"))
1192 (error "Cannot write to file %s" file)))
1193 t))))
1195 (defun reftex-check-parse-consistency ()
1196 ;; Check if parse file is consistent, throw an error if not.
1198 ;; Check if the master is the same: when moving a document, this will see it.
1199 (let* ((real-master (reftex-TeX-master-file))
1200 (parsed-master
1201 (nth 1 (assq 'bof (symbol-value reftex-docstruct-symbol)))))
1202 (unless (string= (file-truename real-master) (file-truename parsed-master))
1203 (message "Master file name in load file is different: %s versus %s"
1204 parsed-master real-master)
1205 (error "Master file name error")))
1207 ;; Check for the existence of all document files
1208 ;;; (let* ((all (symbol-value reftex-docstruct-symbol)))
1209 ;;; (while all
1210 ;;; (when (and (eq (car (car all)) 'bof)
1211 ;;; (not (file-regular-p (nth 1 (car all)))))
1212 ;;; (message "File %s in saved parse info not available" (cdr (car all)))
1213 ;;; (error "File not found"))
1214 ;;; (setq all (cdr all))))
1217 (defun reftex-select-external-document (xr-alist xr-index)
1218 ;; Return index of an external document.
1219 (let* ((len (length xr-alist)) (highest (1- (+ ?0 len)))
1220 (prompt (format "[%c-%c] Select TAB: Read prefix with completion"
1221 ?0 highest))
1222 key prefix)
1223 (cond
1224 ((= len 1)
1225 (message "No external documents available")
1226 (ding) (sit-for 1) 0)
1227 ((= len 2)
1228 (- 1 xr-index))
1230 (save-excursion
1231 (let* ((length (apply 'max (mapcar
1232 (lambda(x) (length (car x))) xr-alist)))
1233 (fmt (format " [%%c] %%-%ds %%s\n" length))
1234 (n (1- ?0)))
1235 (setq key
1236 (reftex-select-with-char
1237 prompt
1238 (concat
1239 "SELECT EXTERNAL DOCUMENT\n------------------------\n"
1240 (mapconcat
1241 (lambda (x)
1242 (format fmt (incf n) (or (car x) "")
1243 (abbreviate-file-name (cdr x))))
1244 xr-alist ""))
1245 nil t))
1246 (cond
1247 ((and (>= key ?0) (<= key highest)) (- key ?0))
1248 ((= key ?\C-i)
1249 (setq prefix (completing-read "Prefix: " xr-alist nil t))
1250 (- len (length (memq (assoc prefix xr-alist) xr-alist))))
1251 (t (error "Invalid document selection [%c]" key)))))))))
1253 ;;; =========================================================================
1255 ;;; Finding files
1257 (defun reftex-locate-file (file type master-dir &optional die)
1258 "Find FILE of type TYPE in MASTER-DIR or on the path associated with TYPE.
1259 If the file does not have any of the valid extensions for TYPE,
1260 try first the default extension and only then the naked file name.
1261 When DIE is non-nil, throw an error if file not found."
1262 (let* ((rec-values (if reftex-search-unrecursed-path-first '(nil t) '(t)))
1263 (extensions (cdr (assoc type reftex-file-extensions)))
1264 (def-ext (car extensions))
1265 (ext-re (concat "\\("
1266 (mapconcat 'regexp-quote extensions "\\|")
1267 "\\)\\'"))
1268 (files (if (string-match ext-re file)
1269 (cons file nil)
1270 (if reftex-try-all-extensions
1271 (append (mapcar (lambda (x) (concat file x))
1272 extensions)
1273 (list file))
1274 (list (concat file def-ext) file))))
1275 path old-path file1 f fs)
1276 (cond
1277 ((file-name-absolute-p file)
1278 (while (setq f (pop files))
1279 (if (file-regular-p f)
1280 (setq file1 f files nil))))
1281 ((and reftex-use-external-file-finders
1282 (assoc type reftex-external-file-finders))
1283 (setq file1 (reftex-find-file-externally file type master-dir)))
1285 (while (and (null file1) rec-values)
1286 (setq path (reftex-access-search-path
1287 type (pop rec-values) master-dir file))
1288 (setq fs files)
1289 (while (and (null file1) (setq f (pop fs)))
1290 (when (or (null old-path)
1291 (not (eq old-path path)))
1292 (setq old-path path
1293 path (cons master-dir path))
1294 (setq file1 (reftex-find-file-on-path f path master-dir)))))))
1295 (cond (file1 file1)
1296 (die (error "No such file: %s" file) nil)
1297 (t (message "No such file: %s (ignored)" file) nil))))
1299 (defun reftex-find-file-externally (file type &optional master-dir)
1300 ;; Use external program to find FILE.
1301 ;; The program is taken from `reftex-external-file-finders'.
1302 ;; Interpret relative path definitions starting from MASTER-DIR.
1303 (let ((default-directory (or master-dir default-directory))
1304 (prg (cdr (assoc type reftex-external-file-finders)))
1305 out)
1306 (if (string-match "%f" prg)
1307 (setq prg (replace-match file t t prg)))
1308 (setq out (apply 'reftex-process-string (split-string prg)))
1309 (if (string-match "[ \t\n]+\\'" out) ; chomp
1310 (setq out (replace-match "" nil nil out)))
1311 (cond ((equal out "") nil)
1312 ((file-regular-p out) (expand-file-name out master-dir))
1313 (t nil))))
1315 (defun reftex-process-string (program &rest args)
1316 "Execute PROGRAM with arguments ARGS and return its STDOUT as a string."
1317 (let ((calling-dir default-directory)) ; remember default directory
1318 (with-output-to-string
1319 (with-current-buffer standard-output
1320 (let ((default-directory calling-dir)) ; set default directory
1321 (apply 'call-process program nil '(t nil) nil args))))))
1323 (defun reftex-access-search-path (type &optional recurse master-dir file)
1324 ;; Access path from environment variables. TYPE is either "tex" or "bib".
1325 ;; When RECURSE is t, expand path elements ending in `//' recursively.
1326 ;; Relative path elements are left as they are. However, relative recursive
1327 ;; elements are expanded with MASTER-DIR as default directory.
1328 ;; The expanded path is cached for the next search.
1329 ;; FILE is just for the progress message.
1330 ;; Returns the derived path.
1331 (let* ((pathvar (intern (concat "reftex-" type "-path"))))
1332 (when (null (get pathvar 'status))
1333 ;; Get basic path
1334 (set pathvar
1335 (reftex-uniquify
1336 (reftex-parse-colon-path
1337 (mapconcat
1338 (lambda(x)
1339 (if (string-match "^!" x)
1340 (apply 'reftex-process-string
1341 (split-string (substring x 1)))
1342 (or (getenv x) x)))
1343 ;; For consistency, the next line should look like this:
1344 ;; (cdr (assoc type reftex-path-environment))
1345 ;; However, historically we have separate options for the
1346 ;; environment variables, so we have to do this:
1347 (symbol-value (intern (concat "reftex-" type
1348 "path-environment-variables")))
1349 path-separator))))
1350 (put pathvar 'status 'split)
1351 ;; Check if we have recursive elements
1352 (let ((path (symbol-value pathvar)) dir rec)
1353 (while (setq dir (pop path))
1354 (when (string= (substring dir -2) "//")
1355 (if (file-name-absolute-p dir)
1356 (setq rec (or rec 'absolute))
1357 (setq rec 'relative))))
1358 (put pathvar 'rec-type rec)))
1360 (if recurse
1361 ;; Return the recursive expansion of the path
1362 (cond
1363 ((not (get pathvar 'rec-type))
1364 ;; Path does not contain recursive elements - use simple path
1365 (symbol-value pathvar))
1366 ((or (not (get pathvar 'recursive-path))
1367 (and (eq (get pathvar 'rec-type) 'relative)
1368 (not (equal master-dir (get pathvar 'master-dir)))))
1369 ;; Either: We don't have a recursive expansion yet.
1370 ;; or: Relative recursive path elements need to be expanded
1371 ;; relative to new default directory
1372 (message "Expanding search path to find %s file: %s ..." type file)
1373 (put pathvar 'recursive-path
1374 (reftex-expand-path (symbol-value pathvar) master-dir))
1375 (put pathvar 'master-dir master-dir)
1376 (get pathvar 'recursive-path))
1378 ;; Recursive path computed earlier is still OK.
1379 (get pathvar 'recursive-path)))
1380 ;; The simple path was requested
1381 (symbol-value pathvar))))
1383 (defun reftex-find-file-on-path (file path &optional def-dir)
1384 ;; Find FILE along the directory list PATH.
1385 ;; DEF-DIR is the default directory for expanding relative path elements.
1386 (catch 'exit
1387 (when (file-name-absolute-p file)
1388 (if (file-regular-p file)
1389 (throw 'exit file)
1390 (throw 'exit nil)))
1391 (let* ((thepath path) file1 dir)
1392 (while (setq dir (pop thepath))
1393 (when (string= (substring dir -2) "//")
1394 (setq dir (substring dir 0 -1)))
1395 (setq file1 (expand-file-name file (expand-file-name dir def-dir)))
1396 (if (file-regular-p file1)
1397 (throw 'exit file1)))
1398 ;; No such file
1399 nil)))
1401 (defun reftex-parse-colon-path (path)
1402 ;; Like parse-colon-parse, but // or /~ are left alone.
1403 ;; Trailing ! or !! will be converted into `//' (emTeX convention)
1404 (mapcar
1405 (lambda (dir)
1406 (if (string-match "\\(//+\\|/*!+\\)\\'" dir)
1407 (setq dir (replace-match "//" t t dir)))
1408 (file-name-as-directory dir))
1409 (delete "" (split-string path (concat path-separator "+")))))
1411 (defun reftex-expand-path (path &optional default-dir)
1412 ;; Expand parts of path ending in `//' recursively into directory list.
1413 ;; Relative recursive path elements are expanded relative to DEFAULT-DIR.
1414 (let (path1 dir recursive)
1415 (while (setq dir (pop path))
1416 (if (setq recursive (string= (substring dir -2) "//"))
1417 (setq dir (substring dir 0 -1)))
1418 (if (and recursive
1419 (not (file-name-absolute-p dir)))
1420 (setq dir (expand-file-name dir default-dir)))
1421 (if recursive
1422 ;; Expand recursively
1423 (setq path1 (append (reftex-recursive-directory-list dir) path1))
1424 ;; Keep unchanged
1425 (push dir path1)))
1426 (nreverse path1)))
1428 (defun reftex-recursive-directory-list (dir)
1429 ;; Return a list of all directories below DIR, including DIR itself
1430 (let ((path (list dir)) path1 file files)
1431 (while (setq dir (pop path))
1432 (when (file-directory-p dir)
1433 (setq files (nreverse (directory-files dir t "[^.]")))
1434 (while (setq file (pop files))
1435 (if (file-directory-p file)
1436 (push (file-name-as-directory file) path)))
1437 (push dir path1)))
1438 path1))
1440 ;;; =========================================================================
1442 ;;; Some generally useful functions
1444 (defun reftex-typekey-check (typekey conf-variable &optional n)
1445 ;; Check if CONF-VARIABLE is true or contains TYPEKEY
1446 (and n (setq conf-variable (nth n conf-variable)))
1447 (or (eq conf-variable t)
1448 (and (stringp conf-variable)
1449 (string-match (concat "[" conf-variable "]") typekey))))
1451 (defun reftex-check-recursive-edit ()
1452 ;; Check if we are already in a recursive edit. Abort with helpful
1453 ;; message if so.
1454 (if (marker-position reftex-recursive-edit-marker)
1455 (error
1456 (substitute-command-keys
1457 "In unfinished selection process. Finish, or abort with \\[abort-recursive-edit]"))))
1459 (defun reftex-in-comment ()
1460 "Return non-nil if point is in a comment."
1461 (save-excursion
1462 (save-match-data
1463 (let ((pos (point)))
1464 (beginning-of-line)
1465 (re-search-forward
1466 (or comment-start-skip
1467 ;; The parser may open files in fundamental mode if
1468 ;; `reftex-initialize-temporary-buffers' is nil, so here
1469 ;; is a default suitable for plain TeX and LaTeX.
1470 "\\(\\(^\\|[^\\\n]\\)\\(\\\\\\\\\\)*\\)\\(%+[ \t]*\\)")
1471 pos t)))))
1473 (defun reftex-no-props (string)
1474 ;; Return STRING with all text properties removed
1475 (and (stringp string)
1476 (set-text-properties 0 (length string) nil string))
1477 string)
1479 (defun reftex-match-string (n)
1480 ;; Match string without properties
1481 (when (match-beginning n)
1482 (buffer-substring-no-properties (match-beginning n) (match-end n))))
1484 (defun reftex-region-active-p ()
1485 "Should we operate on an active region?"
1486 (if (fboundp 'use-region-p)
1487 (use-region-p)
1488 ;; For XEmacs.
1489 (region-active-p)))
1491 (defun reftex-kill-buffer (buffer)
1492 ;; Kill buffer if it exists.
1493 (and (setq buffer (get-buffer buffer))
1494 (kill-buffer buffer)))
1496 (defun reftex-erase-buffer (&optional buffer)
1497 ;; Erase BUFFER if it exists. BUFFER defaults to current buffer.
1498 ;; This even erases read-only buffers.
1499 (cond
1500 ((null buffer)
1501 ;; erase current buffer
1502 (let ((buffer-read-only nil)) (erase-buffer)))
1503 ((setq buffer (get-buffer buffer))
1504 ;; buffer exists
1505 (with-current-buffer buffer
1506 (let ((inhibit-read-only t)) (erase-buffer))))))
1508 (defun reftex-this-word (&optional class)
1509 ;; Grab the word around point.
1510 (setq class (or class "-a-zA-Z0-9:_/.*;|"))
1511 (save-excursion
1512 (buffer-substring-no-properties
1513 (progn (skip-chars-backward class) (point))
1514 (progn (skip-chars-forward class) (point)))))
1516 (defun reftex-number (n unit &optional ending)
1517 (if (and (integerp n) (stringp unit))
1518 (format "%d %s%s" n unit (if (= n 1) "" (or ending "s")))
1519 ""))
1521 (defun reftex-all-assq (key list)
1522 ;; Return a list of all associations of KEY in LIST. Comparison with eq.
1523 (let (rtn)
1524 (while (setq list (memq (assq key list) list))
1525 (push (car list) rtn)
1526 (pop list))
1527 (nreverse rtn)))
1529 (defun reftex-all-assoc-string (key list)
1530 ;; Return a list of all associations of KEY in LIST. Comparison with string=.
1531 (let (rtn)
1532 (while list
1533 (if (string= (car (car list)) key)
1534 (push (car list) rtn))
1535 (pop list))
1536 (nreverse rtn)))
1538 (defun reftex-last-assoc-before-elt (key elt list &optional exclusive)
1539 ;; Find the last association of KEY in LIST before or at ELT
1540 ;; ELT is found in LIST with equal, not eq.
1541 ;; Returns nil when either KEY or elt are not found in LIST.
1542 ;; When EXCLUSIVE is non-nil, ELT cannot be the return value.
1543 ;; On success, returns the association.
1544 (let* ((elt (car (member elt list))) (ex (not exclusive)) ass last-ass)
1545 (while (and (setq ass (assoc key list))
1546 (setq list (memq ass list))
1547 (or ex (not (eq elt (car list))))
1548 (memq elt list))
1549 (setq last-ass ass
1550 list (cdr list)))
1551 last-ass))
1553 (defun reftex-sublist-nth (list nth predicate &optional completion)
1554 ;; Make a list of the NTH elements of all members of LIST which
1555 ;; fulfill PREDICATE.
1556 ;; When COMPLETION is non-nil, make all elements of the resulting
1557 ;; list also a list, so that the result can be used for completion.
1558 (let (rtn)
1559 (while list
1560 (if (funcall predicate (car list))
1561 (push (if completion
1562 (list (nth nth (car list)))
1563 (nth nth (car list)))
1564 rtn))
1565 (setq list (cdr list)))
1566 (nreverse rtn)))
1568 (defun reftex-make-selection-buffer-name (type &optional index)
1569 ;; Make unique name for a selection buffer.
1570 (format " *RefTeX[%s][%d]*"
1571 type (or index (get reftex-docstruct-symbol :master-index) 0)))
1573 (defun reftex-make-index-buffer-name (tag &optional cnt)
1574 ;; Make unique name for an index buffer.
1575 (format "*Index[%s][%d]*"
1576 tag (or cnt (get reftex-docstruct-symbol :master-index) 0)))
1578 (defun reftex-truncate (string ncols &optional ellipses padding)
1579 ;; Truncate STRING to NCOLS characters.
1580 ;; When PADDING is non-nil, and string is shorter than NCOLS, fill with
1581 ;; white space to NCOLS characters. When ELLIPSES is non-nil and the
1582 ;; string needs to be truncated, replace last 3 characters by dots.
1583 (setq string
1584 (if (<= (length string) ncols)
1585 string
1586 (if ellipses
1587 (concat (substring string 0 (- ncols 3)) "...")
1588 (substring string 0 ncols))))
1589 (if padding
1590 (format (format "%%-%ds" ncols) string)
1591 string))
1593 (defun reftex-nearest-match (regexp &optional max-length)
1594 ;; Find the nearest match of REGEXP. Set the match data.
1595 ;; If POS is given, calculate distances relative to it.
1596 ;; Return nil if there is no match.
1597 (let ((pos (point))
1598 (dist (or max-length (length regexp)))
1599 match1 match2 match)
1600 (goto-char (min (+ pos dist) (point-max)))
1601 (when (re-search-backward regexp nil t)
1602 (setq match1 (match-data)))
1603 (goto-char (max (- pos dist) (point-min)))
1604 (when (re-search-forward regexp nil t)
1605 (setq match2 (match-data)))
1606 (goto-char pos)
1607 (setq match
1608 (cond
1609 ((not match1) match2)
1610 ((not match2) match1)
1611 ((< (abs (- pos (car match1))) (abs (- pos (car match2)))) match1)
1612 (t match2)))
1613 (if match (progn (set-match-data match) t) nil)))
1615 (defun reftex-auto-mode-alist ()
1616 ;; Return an `auto-mode-alist' with only the .gz (etc) thingies.
1617 ;; Stolen from gnus nnheader.
1618 (let ((alist auto-mode-alist)
1619 out)
1620 (while alist
1621 (when (listp (cdr (car alist)))
1622 (push (car alist) out))
1623 (pop alist))
1624 (nreverse out)))
1626 (defun reftex-window-height ()
1627 (if (fboundp 'window-displayed-height)
1628 (window-displayed-height)
1629 (window-height)))
1631 (defun reftex-enlarge-to-fit (buf2 &optional keep-current)
1632 ;; Enlarge other window displaying buffer to show whole buffer if possible.
1633 ;; If KEEP-CURRENT in non-nil, current buffer must remain visible.
1634 (let* ((win1 (selected-window))
1635 (buf1 (current-buffer))
1636 (win2 (get-buffer-window buf2))) ;; Only on current frame.
1637 (when win2
1638 (select-window win2)
1639 (unless (and (pos-visible-in-window-p (point-min))
1640 (pos-visible-in-window-p (point-max)))
1641 (enlarge-window (1+ (- (count-lines (point-min) (point-max))
1642 (reftex-window-height))))))
1643 (cond
1644 ((window-live-p win1) (select-window win1))
1645 (keep-current
1646 ;; we must have the old buffer!
1647 (switch-to-buffer-other-window buf1)
1648 (shrink-window (- (window-height) window-min-height))))))
1650 (defun reftex-select-with-char (prompt help-string &optional delay-time scroll)
1651 ;; Offer to select something with PROMPT and, after DELAY-TIME seconds,
1652 ;; also with HELP-STRING.
1653 ;; When SCROLL is non-nil, use SPC and DEL to scroll help window.
1654 (let ((char ?\?))
1655 (save-window-excursion
1656 (catch 'exit
1657 (message "%s (?=Help)" prompt)
1658 (when (or (sit-for (or delay-time 0))
1659 (= ?\? (setq char (read-char-exclusive))))
1660 (reftex-kill-buffer "*RefTeX Select*")
1661 (switch-to-buffer-other-window "*RefTeX Select*")
1662 (insert help-string)
1663 (goto-char 1)
1664 (unless (and (pos-visible-in-window-p (point-min))
1665 (pos-visible-in-window-p (point-max)))
1666 (enlarge-window (1+ (- (count-lines (point-min) (point-max))
1667 (reftex-window-height)))))
1668 (setq truncate-lines t))
1669 (if (and (pos-visible-in-window-p (point-min))
1670 (pos-visible-in-window-p (point-max)))
1672 (setq prompt (concat prompt (if scroll " (SPC/DEL=Scroll)" ""))))
1673 (message "%s" prompt)
1674 (and (equal char ?\?) (setq char (read-char-exclusive)))
1675 (while t
1676 (cond ((equal char ?\C-g) (keyboard-quit))
1677 ((equal char ?\?))
1678 ((and scroll (equal char ?\ ))
1679 (condition-case nil (scroll-up) (error nil))
1680 (message "%s" prompt))
1681 ((and scroll (equal char ?\C-? ))
1682 (condition-case nil (scroll-down) (error nil))
1683 (message "%s" prompt))
1684 (t (message "")
1685 (reftex-kill-buffer "*RefTeX Select*")
1686 (throw 'exit char)))
1687 (setq char (read-char-exclusive)))))))
1690 (defun reftex-make-regexp-allow-for-ctrl-m (string)
1691 ;; convert STRING into a regexp, allowing ^M for \n and vice versa
1692 (let ((start -2))
1693 (setq string (regexp-quote string))
1694 (while (setq start (string-match "[\n\r]" string (+ 3 start)))
1695 (setq string (replace-match "[\n\r]" nil t string)))
1696 string))
1698 (defun reftex-get-buffer-visiting (file)
1699 ;; return a buffer visiting FILE
1700 (cond
1701 ((boundp 'find-file-compare-truenames) ; XEmacs
1702 (let ((find-file-compare-truenames t))
1703 (get-file-buffer file)))
1704 ((fboundp 'find-buffer-visiting) ; Emacs
1705 (find-buffer-visiting file))
1706 (t (error "This should not happen (reftex-get-buffer-visiting)"))))
1708 ;; Define `current-message' for compatibility with XEmacs prior to 20.4
1709 (defvar message-stack)
1710 (if (and (featurep 'xemacs)
1711 (not (fboundp 'current-message)))
1712 (defun current-message (&optional frame)
1713 (cdr (car message-stack))))
1715 (defun reftex-visited-files (list)
1716 ;; Takes a list of filenames and returns the buffers of those already visited
1717 (delq nil (mapcar (lambda (x) (if (reftex-get-buffer-visiting x) x nil))
1718 list)))
1720 (defun reftex-get-file-buffer-force (file &optional mark-to-kill)
1721 ;; Return a buffer visiting file. Make one, if necessary.
1722 ;; If neither such a buffer nor the file exist, return nil.
1723 ;; If MARK-TO-KILL is t and there is no live buffer, visit the file with
1724 ;; initializations according to `reftex-initialize-temporary-buffers',
1725 ;; and mark the buffer to be killed after use.
1727 (let ((buf (reftex-get-buffer-visiting file)))
1729 (cond (buf
1730 ;; We have it already as a buffer - just return it
1731 buf)
1733 ((file-readable-p file)
1734 ;; At least there is such a file and we can read it.
1736 (if (or (not mark-to-kill)
1737 (eq t reftex-initialize-temporary-buffers))
1739 ;; Visit the file with full magic
1740 (setq buf (find-file-noselect file))
1742 ;; Else: Visit the file just briefly, without or
1743 ;; with limited Magic
1745 ;; The magic goes away
1746 (letf ((format-alist nil)
1747 (auto-mode-alist (reftex-auto-mode-alist))
1748 ((default-value 'major-mode) 'fundamental-mode)
1749 (enable-local-variables nil)
1750 (after-insert-file-functions nil))
1751 (setq buf (find-file-noselect file)))
1753 ;; Is there a hook to run?
1754 (when (listp reftex-initialize-temporary-buffers)
1755 (with-current-buffer buf
1756 (run-hooks 'reftex-initialize-temporary-buffers))))
1758 ;; Let's see if we got a license to kill :-|
1759 (and mark-to-kill
1760 (add-to-list 'reftex-buffers-to-kill buf))
1762 ;; Return the new buffer
1763 buf)
1765 ;; If no such file exists, return nil
1766 (t nil))))
1768 (defun reftex-kill-temporary-buffers (&optional buffer)
1769 ;; Kill all buffers in the list reftex-kill-temporary-buffers.
1770 (cond
1771 (buffer
1772 (when (member buffer reftex-buffers-to-kill)
1773 (kill-buffer buffer)
1774 (setq reftex-buffers-to-kill
1775 (delete buffer reftex-buffers-to-kill))))
1777 (while (setq buffer (pop reftex-buffers-to-kill))
1778 (when (bufferp buffer)
1779 (and (buffer-modified-p buffer)
1780 (y-or-n-p (format "Save file %s? "
1781 (buffer-file-name buffer)))
1782 (with-current-buffer buffer
1783 (save-buffer)))
1784 (kill-buffer buffer))
1785 (pop reftex-buffers-to-kill)))))
1787 (defun reftex-splice-symbols-into-list (list alist)
1788 ;; Splice the association in ALIST of any symbols in LIST into the list.
1789 ;; Return new list.
1790 (let (rtn tmp)
1791 (while list
1792 (while (and (not (null (car list))) ;; keep list elements nil
1793 (symbolp (car list)))
1794 (setq tmp (car list))
1795 (cond
1796 ((assoc tmp alist)
1797 (setq list (append (nth 2 (assoc tmp alist)) (cdr list))))
1799 (error "Cannot treat symbol %s in reftex-label-alist"
1800 (symbol-name tmp)))))
1801 (push (pop list) rtn))
1802 (nreverse rtn)))
1804 (defun reftex-remove-symbols-from-list (list)
1805 ;; Remove all symbols from list
1806 (let (rtn)
1807 (while list
1808 (unless (symbolp (car list))
1809 (push (car list) rtn))
1810 (setq list (cdr list)))
1811 (nreverse rtn)))
1813 (defun reftex-uniquify (list &optional sort)
1814 ;; Return a list of all strings in LIST, but each only once, keeping order
1815 ;; unless SORT is set (faster!).
1816 (setq list (copy-sequence list))
1817 (if sort
1818 (progn
1819 (setq list (sort list 'string<))
1820 (let ((p list))
1821 (while (cdr p)
1822 (if (string= (car p) (car (cdr p)))
1823 (setcdr p (cdr (cdr p)))
1824 (setq p (cdr p)))))
1825 list)
1826 (let ((p list) lst elt)
1827 ;; push all sublists into lst in reverse(!) order
1828 (while p
1829 (push p lst)
1830 (setq p (cdr p)))
1831 ;; sort all sublists
1832 (setq lst (sort lst (lambda (x1 x2) (string< (car x1) (car x2)))))
1833 (while (cdr lst)
1834 (setq elt (car (car lst)))
1835 ;; for equal elements in the sorted sublist, replace the
1836 ;; last(!) original list member with nil
1837 (when (string= elt (car (cadr lst)))
1838 (setcar (pop lst) nil)
1839 (while (and (cdr lst) (string= elt (car (cadr lst))))
1840 (setcar (pop lst) nil)))
1841 (pop lst)))
1842 ;; weed out all nils and return.
1843 (delq nil list)))
1845 (defun reftex-uniquify-by-car (alist &optional keep-list sort)
1846 ;; Return a list of all elements in ALIST, but each car only once.
1847 ;; Elements of KEEP-LIST are not removed even if duplicate.
1848 ;; The order is kept unless SORT is set (faster!).
1849 (setq keep-list (sort (copy-sequence keep-list) #'string<)
1850 alist (copy-sequence alist))
1851 (if sort
1852 (let (lst elt)
1853 (setq alist (sort alist (lambda(a b) (string< (car a) (car b)))))
1854 (setq lst alist)
1855 (while (cdr lst)
1856 (setq elt (car (car lst)))
1857 (when (string= elt (car (cadr lst)))
1858 (while (and keep-list (string< (car keep-list) elt))
1859 (pop keep-list))
1860 (if (and keep-list (string= elt (car keep-list)))
1861 (progn
1862 (pop lst)
1863 (while (and (cdr lst)
1864 (string= elt (car (cadr lst))))
1865 (pop lst)))
1866 (setcdr lst (cdr (cdr lst)))
1867 (while (and (cdr lst)
1868 (string= elt (car (cadr lst))))
1869 (setcdr lst (cdr (cdr lst))))))
1870 (pop lst))
1871 alist)
1872 (let ((p alist) lst elt)
1873 (while p
1874 (push p lst)
1875 (setq p (cdr p)))
1876 (setq lst (sort lst (lambda(a b) (string< (car (car a))
1877 (car (car b))))))
1878 (while (cdr lst)
1879 (setq elt (car (car (car lst))))
1880 (when (string= elt (car (car (cadr lst))))
1881 (while (and keep-list (string< (car keep-list) elt))
1882 (pop keep-list))
1883 (if (and keep-list (string= elt (car keep-list)))
1884 (progn
1885 (pop lst)
1886 (while (and (cdr lst)
1887 (string= elt (car (car (cadr lst)))))
1888 (pop lst)))
1889 (setcar (pop lst) nil)
1890 (while (and (cdr lst)
1891 (string= elt (car (car (cadr lst)))))
1892 (setcar (pop lst) nil))))
1893 (pop lst)))
1894 (delq nil alist)))
1896 (defun reftex-remove-if (predicate list)
1897 "Nondestructively remove all items from LIST which satisfy PREDICATE."
1898 (let (result)
1899 (dolist (elt list (nreverse result))
1900 (unless (funcall predicate elt)
1901 (push elt result)))))
1903 (defun reftex-abbreviate-title (string)
1904 (reftex-convert-string string "[-~ \t\n\r,;]" nil t t
1905 5 40 nil 1 " " (nth 5 reftex-derive-label-parameters)))
1907 (defun reftex-convert-string (string split-re invalid-re dot keep-fp
1908 nwords maxchar invalid abbrev sep
1909 ignore-words &optional downcase)
1910 "Convert a string (a sentence) to something shorter.
1911 SPLIT-RE is the regular expression used to split the string into words.
1912 INVALID-RE matches characters which are invalid in the final string.
1913 DOT t means add dots to abbreviated words.
1914 KEEP-FP t means to keep a final punctuation when applicable.
1915 NWORDS Number of words to use.
1916 MAXCHAR Maximum number of characters in the final string.
1917 INVALID nil: Throw away any words containing stuff matched with INVALID-RE.
1918 t: Throw away only the matched part, not the whole word.
1919 ABBREV nil: Never abbreviate words.
1920 t: Always abbreviate words (see `reftex-abbrev-parameters').
1921 not t and not nil: Abbreviate words if necessary to shorten
1922 string below MAXCHAR.
1923 SEP String separating different words in the output string.
1924 IGNORE-WORDS List of words which should be removed from the string."
1926 (let* ((words0 (split-string string (or split-re "[ \t\n\r]")))
1927 (reftex-label-illegal-re (or invalid-re "\000"))
1928 (abbrev-re (concat
1929 "\\`\\("
1930 (make-string (nth 0 reftex-abbrev-parameters) ?.)
1931 "[" (nth 2 reftex-abbrev-parameters) "]*"
1932 "\\)"
1933 "[" (nth 3 reftex-abbrev-parameters) "]"
1934 (make-string (1- (nth 1 reftex-abbrev-parameters)) ?.)))
1935 words word)
1937 ;; Remove words from the ignore list or with funny characters
1938 (while (setq word (pop words0))
1939 (if downcase (setq word (downcase word)))
1940 (cond
1941 ((member (downcase word) ignore-words))
1942 ((string-match reftex-label-illegal-re word)
1943 (when invalid
1944 (while (string-match reftex-label-illegal-re word)
1945 (setq word (replace-match "" nil nil word)))
1946 (push word words)))
1948 (push word words))))
1949 (setq words (nreverse words))
1951 ;; Restrict number of words
1952 (if (> (length words) nwords)
1953 (setcdr (nthcdr (1- nwords) words) nil))
1955 ;; First, try to use all words
1956 (setq string (mapconcat 'identity words sep))
1958 ;; Abbreviate words if enforced by user settings or string length
1959 (if (or (eq t abbrev)
1960 (and abbrev
1961 (> (length string) maxchar)))
1962 (setq words
1963 (mapcar
1964 (lambda (w) (if (string-match abbrev-re w)
1965 (if dot
1966 (concat (match-string 1 w) ".")
1967 (match-string 1 w))
1969 words)
1970 string (mapconcat 'identity words sep)))
1972 ;; Shorten if still to long
1973 (setq string
1974 (if (> (length string) maxchar)
1975 (substring string 0 maxchar)
1976 string))
1978 ;; Delete the final punctuation, if any
1979 (if (and (not keep-fp) (string-match "\\s.+\\'" string))
1980 (setq string (replace-match "" nil nil string)))
1981 string))
1983 (defun reftex-nicify-text (text)
1984 ;; Make TEXT nice for inclusion as context into label menu.
1985 ;; 1. remove line breaks and extra white space
1986 (while (string-match "[\n\r\t]\\|[ \t][ \t]+" text)
1987 (setq text (replace-match " " nil t text)))
1988 ;; 2. cut before the next `\end{' or `\item' or `\\'
1989 (if (string-match "\\(\\\\end{\\|\\\\item\\|\\\\\\\\\\).*" text)
1990 (setq text (replace-match "" nil t text)))
1991 ;; 3. kill the embedded label
1992 (if (string-match "\\\\label{[^}]*}" text)
1993 (setq text (replace-match "" nil t text)))
1994 ;; 4. remove leading garbage
1995 (if (string-match "\\`[ }]+" text)
1996 (setq text (replace-match "" nil t text)))
1997 ;; 5. limit length
1998 (cond
1999 ((> (length text) 100) (substring text 0 100))
2000 ((= (length text) 0) (make-string 1 ?\ ))
2001 (t text)))
2004 ;;; =========================================================================
2006 ;;; Fontification and Highlighting
2008 (defun reftex-use-fonts ()
2009 ;; Return t if we can and want to use fonts.
2010 (and ; window-system
2011 reftex-use-fonts
2012 (featurep 'font-lock)))
2014 (defun reftex-refontify ()
2015 ;; Return t if we need to refontify context
2016 (and (reftex-use-fonts)
2017 (or (eq t reftex-refontify-context)
2018 (and (eq 1 reftex-refontify-context)
2019 ;; Test of we use the font-lock version of x-symbol
2020 (and (featurep 'x-symbol-tex) (not (boundp 'x-symbol-mode)))))))
2022 (defvar font-lock-defaults-computed)
2023 (defun reftex-fontify-select-label-buffer (parent-buffer)
2024 ;; Fontify the `*RefTeX Select*' buffer. Buffer is temporarily renamed to
2025 ;; start with none-SPC char, because Font-Lock otherwise refuses operation.
2026 (run-hook-with-args 'reftex-pre-refontification-functions
2027 parent-buffer 'reftex-ref)
2028 (let* ((oldname (buffer-name))
2029 (newname (concat "Fontify-me-" oldname)))
2030 (unwind-protect
2031 (progn
2032 ;; Rename buffer temporarily to start w/o space (because of font-lock)
2033 (rename-buffer newname t)
2034 (cond
2035 ((fboundp 'font-lock-default-fontify-region)
2036 ;; Good: we have the indirection functions
2037 (set (make-local-variable 'font-lock-fontify-region-function)
2038 'reftex-select-font-lock-fontify-region)
2039 (let ((major-mode 'latex-mode))
2040 (font-lock-mode 1)))
2041 ((fboundp 'font-lock-set-defaults-1)
2042 ;; Looks like the XEmacs font-lock stuff.
2043 ;; FIXME: this is still kind of a hack, but it works.
2044 (set (make-local-variable 'font-lock-keywords) nil)
2045 (let ((major-mode 'latex-mode)
2046 (font-lock-defaults-computed nil))
2047 (font-lock-set-defaults-1)
2048 (reftex-select-font-lock-fontify-region (point-min) (point-max))))
2050 ;; Oops?
2051 (message "Sorry: cannot refontify RefTeX Select buffer."))))
2052 (rename-buffer oldname))))
2054 (defun reftex-select-font-lock-fontify-region (beg end &optional loudly)
2055 ;; Fontify a region, but only lines starting with a dot.
2056 (let ((func (if (fboundp 'font-lock-default-fontify-region)
2057 'font-lock-default-fontify-region
2058 'font-lock-fontify-region))
2059 beg1 end1)
2060 (goto-char beg)
2061 (while (re-search-forward "^\\." end t)
2062 (setq beg1 (point) end1 (progn (skip-chars-forward "^\n") (point)))
2063 (funcall func beg1 end1 nil)
2064 (goto-char end1))))
2066 (defun reftex-select-font-lock-unfontify (&rest ignore) t)
2068 (defun reftex-verified-face (&rest faces)
2069 ;; Return the first valid face in FACES, or nil if none is valid.
2070 ;; Also, when finding a nil element in FACES, return nil. This
2071 ;; function is just a safety net to catch name changes of builtin
2072 ;; fonts. Currently it is only used for reftex-label-face.
2073 (let (face)
2074 (catch 'exit
2075 (while (setq face (pop faces))
2076 (if (featurep 'xemacs)
2077 (if (find-face face) (throw 'exit face))
2078 (if (facep face) (throw 'exit face)))))))
2080 ;; Highlighting uses overlays. For XEmacs, we use extends.
2081 (defalias 'reftex-make-overlay
2082 (if (featurep 'xemacs) 'make-extent 'make-overlay))
2083 (defalias 'reftex-overlay-put
2084 (if (featurep 'xemacs) 'set-extent-property 'overlay-put))
2085 (defalias 'reftex-move-overlay
2086 (if (featurep 'xemacs) 'set-extent-endpoints 'move-overlay))
2087 (defalias 'reftex-delete-overlay
2088 (if (featurep 'xemacs) 'detach-extent 'delete-overlay))
2090 ;; We keep a vector with several different overlays to do our highlighting.
2091 (defvar reftex-highlight-overlays [nil nil nil])
2093 ;; Initialize the overlays
2094 (aset reftex-highlight-overlays 0 (reftex-make-overlay 1 1))
2095 (reftex-overlay-put (aref reftex-highlight-overlays 0)
2096 'face 'highlight)
2097 (aset reftex-highlight-overlays 1 (reftex-make-overlay 1 1))
2098 (reftex-overlay-put (aref reftex-highlight-overlays 1)
2099 'face reftex-cursor-selected-face)
2100 (aset reftex-highlight-overlays 2 (reftex-make-overlay 1 1))
2101 (reftex-overlay-put (aref reftex-highlight-overlays 2)
2102 'face reftex-cursor-selected-face)
2104 ;; Two functions for activating and deactivation highlight overlays
2105 (defun reftex-highlight (index begin end &optional buffer)
2106 "Highlight a region with overlay INDEX."
2107 (reftex-move-overlay (aref reftex-highlight-overlays index)
2108 begin end (or buffer (current-buffer))))
2109 (defun reftex-unhighlight (index)
2110 "Detach overlay INDEX."
2111 (reftex-delete-overlay (aref reftex-highlight-overlays index)))
2113 (defun reftex-highlight-shall-die ()
2114 ;; Function used in pre-command-hook to remove highlights.
2115 (remove-hook 'pre-command-hook 'reftex-highlight-shall-die)
2116 (reftex-unhighlight 0))
2118 ;;; =========================================================================
2120 ;;; Keybindings
2122 ;; The default bindings in the mode map.
2123 (loop for x in
2124 '(("\C-c=" . reftex-toc)
2125 ("\C-c-" . reftex-toc-recenter)
2126 ("\C-c(" . reftex-label)
2127 ("\C-c)" . reftex-reference)
2128 ("\C-c[" . reftex-citation)
2129 ("\C-c<" . reftex-index)
2130 ("\C-c>" . reftex-display-index)
2131 ("\C-c/" . reftex-index-selection-or-word)
2132 ("\C-c\\" . reftex-index-phrase-selection-or-word)
2133 ("\C-c|" . reftex-index-visit-phrases-buffer)
2134 ("\C-c&" . reftex-view-crossref))
2135 do (define-key reftex-mode-map (car x) (cdr x)))
2137 ;; Bind `reftex-mouse-view-crossref' only when the key is still free
2138 (if (featurep 'xemacs)
2139 (unless (key-binding [(shift button2)])
2140 (define-key reftex-mode-map [(shift button2)]
2141 'reftex-mouse-view-crossref))
2142 (unless (key-binding [(shift mouse-2)])
2143 (define-key reftex-mode-map [(shift mouse-2)]
2144 'reftex-mouse-view-crossref)))
2146 (defvar bibtex-mode-map)
2148 ;; Bind `reftex-view-crossref-from-bibtex' in BibTeX mode map
2149 (eval-after-load
2150 "bibtex"
2151 '(define-key bibtex-mode-map "\C-c&" 'reftex-view-crossref-from-bibtex))
2153 ;; For most of these commands there are already bindings in place.
2154 ;; Setting `reftex-extra-bindings' really is only there to spare users
2155 ;; the hassle of defining bindings in the user space themselves. This
2156 ;; is why they violate the key binding recommendations.
2157 (when reftex-extra-bindings
2158 (loop for x in
2159 '(("\C-ct" . reftex-toc)
2160 ("\C-cl" . reftex-label)
2161 ("\C-cr" . reftex-reference)
2162 ("\C-cc" . reftex-citation)
2163 ("\C-cv" . reftex-view-crossref)
2164 ("\C-cg" . reftex-grep-document)
2165 ("\C-cs" . reftex-search-document))
2166 do (define-key reftex-mode-map (car x) (cdr x))))
2168 ;;; =========================================================================
2170 ;;; Menu
2172 ;; Define a menu for the menu bar if Emacs is running under X
2174 (defvar reftex-isearch-minor-mode nil)
2175 (make-variable-buffer-local 'reftex-isearch-minor-mode)
2177 (easy-menu-define reftex-mode-menu reftex-mode-map
2178 "Menu used in RefTeX mode"
2179 `("Ref"
2180 ["Table of Contents" reftex-toc t]
2181 ["Recenter TOC" reftex-toc-recenter t]
2182 "--"
2183 ["\\label" reftex-label t]
2184 ["\\ref" reftex-reference t]
2185 ["\\cite" reftex-citation t]
2186 ("\\index"
2187 ["\\index" reftex-index t]
2188 ["\\index{THIS}" reftex-index-selection-or-word t]
2189 "--"
2190 ["Add THIS to Index Phrases" reftex-index-phrase-selection-or-word t]
2191 ["Visit Phrase Buffer" reftex-index-visit-phrases-buffer t]
2192 ["Apply Phrases to Region" reftex-index-phrases-apply-to-region t]
2193 "--"
2194 ["Display the Index" reftex-display-index t])
2195 "--"
2196 ["View Crossref" reftex-view-crossref t]
2197 "--"
2198 ("Parse Document"
2199 ["One File" reftex-parse-one reftex-enable-partial-scans]
2200 ["Entire Document" reftex-parse-all t]
2201 ["Save to File" (reftex-access-parse-file 'write)
2202 (> (length (symbol-value reftex-docstruct-symbol)) 0)]
2203 ["Restore from File" (reftex-access-parse-file 'restore) t])
2204 ("Global Actions"
2205 ["Search Whole Document" reftex-search-document t]
2206 ["Search Again" tags-loop-continue t]
2207 ["Replace in Document" reftex-query-replace-document t]
2208 ["Grep on Document" reftex-grep-document t]
2209 "--"
2210 ["Goto Label" reftex-goto-label t]
2211 ["Find Duplicate Labels" reftex-find-duplicate-labels t]
2212 ["Change Label and Refs" reftex-change-label t]
2213 ["Renumber Simple Labels" reftex-renumber-simple-labels t]
2214 "--"
2215 ["Create BibTeX File" reftex-create-bibtex-file t]
2216 "--"
2217 ["Create TAGS File" reftex-create-tags-file t]
2218 "--"
2219 ["Save Document" reftex-save-all-document-buffers t])
2220 "--"
2221 ("Options"
2222 "PARSER"
2223 ["Partial Scans"
2224 (setq reftex-enable-partial-scans (not reftex-enable-partial-scans))
2225 :style toggle :selected reftex-enable-partial-scans]
2226 ["Auto-Save Parse Info"
2227 (setq reftex-save-parse-info (not reftex-save-parse-info))
2228 :style toggle :selected reftex-save-parse-info]
2229 "--"
2230 "TOC RECENTER"
2231 ["Automatic Recenter" reftex-toggle-auto-toc-recenter
2232 :style toggle :selected reftex-toc-auto-recenter-timer]
2233 "--"
2234 "CROSSREF INFO"
2235 ["Automatic Info" reftex-toggle-auto-view-crossref
2236 :style toggle :selected reftex-auto-view-crossref-timer]
2237 ["...in Echo Area" (setq reftex-auto-view-crossref t)
2238 :style radio :selected (eq reftex-auto-view-crossref t)]
2239 ["...in Other Window" (setq reftex-auto-view-crossref 'window)
2240 :style radio :selected (eq reftex-auto-view-crossref 'window)]
2241 "--"
2242 "MISC"
2243 ["AUCTeX Interface" reftex-toggle-plug-into-AUCTeX
2244 :style toggle :selected reftex-plug-into-AUCTeX]
2245 ["isearch whole document" reftex-isearch-minor-mode
2246 :style toggle :selected reftex-isearch-minor-mode])
2247 ("Reference Style"
2248 ,@(let (list item)
2249 (dolist (elt reftex-ref-style-alist)
2250 (setq elt (car elt)
2251 item (vector
2253 `(reftex-ref-style-toggle ,elt)
2254 :style 'toggle
2255 :selected `(member ,elt (reftex-ref-style-list))))
2256 (unless (member item list)
2257 (add-to-list 'list item t)))
2258 list))
2259 ("Citation Style"
2260 ,@(mapcar
2261 (lambda (x)
2262 (vector
2263 (capitalize (symbol-name (car x)))
2264 (list 'reftex-set-cite-format (list 'quote (car x)))
2265 :style 'radio :selected
2266 (list 'eq (list 'reftex-get-cite-format) (list 'quote (car x)))))
2267 reftex-cite-format-builtin)
2268 "--"
2269 "Sort Database Matches"
2270 ["Not" (setq reftex-sort-bibtex-matches nil)
2271 :style radio :selected (eq reftex-sort-bibtex-matches nil)]
2272 ["by Author" (setq reftex-sort-bibtex-matches 'author)
2273 :style radio :selected (eq reftex-sort-bibtex-matches 'author)]
2274 ["by Year" (setq reftex-sort-bibtex-matches 'year)
2275 :style radio :selected (eq reftex-sort-bibtex-matches 'year)]
2276 ["by Year, reversed" (setq reftex-sort-bibtex-matches 'reverse-year)
2277 :style radio :selected (eq reftex-sort-bibtex-matches 'reverse-year)])
2278 ("Index Style"
2279 ,@(mapcar
2280 (lambda (x)
2281 (vector
2282 (capitalize (symbol-name (car x)))
2283 (list 'reftex-add-index-macros (list 'list (list 'quote (car x))))
2284 :style 'radio :selected
2285 (list 'memq (list 'quote (car x))
2286 (list 'get 'reftex-docstruct-symbol
2287 (list 'quote 'reftex-index-macros-style)))))
2288 reftex-index-macros-builtin))
2289 "--"
2290 ["Reset RefTeX Mode" reftex-reset-mode t]
2291 "--"
2292 ("Customize"
2293 ["Browse RefTeX Group" reftex-customize t]
2294 "--"
2295 ["Build Full Customize Menu" reftex-create-customize-menu
2296 (fboundp 'customize-menu-create)])
2297 ("Documentation"
2298 ["Info" reftex-info t]
2299 ["Commentary" reftex-show-commentary t])))
2301 (defun reftex-customize ()
2302 "Call the customize function with reftex as argument."
2303 (interactive)
2304 (customize-browse 'reftex))
2306 (defun reftex-create-customize-menu ()
2307 "Create a full customization menu for RefTeX, insert it into the menu."
2308 (interactive)
2309 (if (fboundp 'customize-menu-create)
2310 (progn
2311 (easy-menu-change
2312 '("Ref") "Customize"
2313 `(["Browse RefTeX group" reftex-customize t]
2314 "--"
2315 ,(customize-menu-create 'reftex)
2316 ["Set" Custom-set t]
2317 ["Save" Custom-save t]
2318 ["Reset to Current" Custom-reset-current t]
2319 ["Reset to Saved" Custom-reset-saved t]
2320 ["Reset to Standard Settings" Custom-reset-standard t]))
2321 (message "\"Ref\"-menu now contains full customization menu"))
2322 (error "Cannot expand menu (outdated version of cus-edit.el)")))
2325 ;;; Misc
2327 (defun reftex-show-commentary ()
2328 "Use the finder to view the file documentation from `reftex.el'."
2329 (interactive)
2330 (finder-commentary "reftex.el"))
2332 (defun reftex-info (&optional node)
2333 "Read documentation for RefTeX in the info system.
2334 With optional NODE, go directly to that node."
2335 (interactive)
2336 (info (format "(reftex)%s" (or node ""))))
2338 (defun reftex-report-bug ()
2339 "Report a bug in RefTeX.
2341 Don't hesitate to report any problems or inaccurate documentation.
2343 If you don't have setup sending mail from (X)Emacs, please copy the
2344 output buffer into your mail program, as it gives us important
2345 information about your RefTeX version and configuration."
2346 (interactive)
2347 (require 'reporter)
2348 (let ((reporter-prompt-for-summary-p "Bug report subject: "))
2349 (reporter-submit-bug-report
2350 "bug-auctex@gnu.org, bug-gnu-emacs@gnu.org"
2351 reftex-version
2352 (list 'window-system
2353 'reftex-plug-into-AUCTeX)
2354 nil nil
2355 "Remember to cover the basics, that is, what you expected to happen and
2356 what in fact did happen.
2358 Check if the bug is reproducible with an up-to-date version of
2359 RefTeX available from http://www.gnu.org/software/auctex/.
2361 If the bug is triggered by a specific \(La\)TeX file, you should try
2362 to produce a minimal sample file showing the problem and include it
2363 in your report.
2365 Your bug report will be posted to the AUCTeX bug reporting list.
2366 ------------------------------------------------------------------------")))
2368 ;;; Install the kill-buffer and kill-emacs hooks ------------------------------
2370 (add-hook 'kill-buffer-hook 'reftex-kill-buffer-hook)
2371 (unless noninteractive
2372 (add-hook 'kill-emacs-hook 'reftex-kill-emacs-hook))
2374 ;;; Run Hook ------------------------------------------------------------------
2376 (run-hooks 'reftex-load-hook)
2378 ;;; That's it! ----------------------------------------------------------------
2380 (setq reftex-tables-dirty t) ; in case this file is evaluated by hand
2383 ;;; Start of automatically extracted autoloads.
2385 ;;;### (autoloads nil "reftex-auc" "reftex-auc.el" "cf606f7918831321cb46f254436dc66e")
2386 ;;; Generated autoloads from reftex-auc.el
2388 (autoload 'reftex-arg-label "reftex-auc" "\
2389 Use `reftex-label', `reftex-reference' or AUCTeX's code to insert label arg.
2390 What is being used depends upon `reftex-plug-into-AUCTeX'.
2392 \(fn OPTIONAL &optional PROMPT DEFINITION)" nil nil)
2394 (autoload 'reftex-arg-cite "reftex-auc" "\
2395 Use `reftex-citation' or AUCTeX's code to insert a cite-key macro argument.
2396 What is being used depends upon `reftex-plug-into-AUCTeX'.
2398 \(fn OPTIONAL &optional PROMPT DEFINITION)" nil nil)
2400 (autoload 'reftex-arg-index-tag "reftex-auc" "\
2401 Prompt for an index tag with completion.
2402 This is the name of an index, not the entry.
2404 \(fn OPTIONAL &optional PROMPT &rest ARGS)" nil nil)
2406 (autoload 'reftex-arg-index "reftex-auc" "\
2407 Prompt for an index entry completing with known entries.
2408 Completion is specific for just one index, if the macro or a tag
2409 argument identify one of multiple indices.
2411 \(fn OPTIONAL &optional PROMPT &rest ARGS)" nil nil)
2413 (autoload 'reftex-plug-into-AUCTeX "reftex-auc" "\
2416 \(fn)" nil nil)
2418 (autoload 'reftex-toggle-plug-into-AUCTeX "reftex-auc" "\
2419 Toggle Interface between AUCTeX and RefTeX on and off.
2421 \(fn)" t nil)
2423 (autoload 'reftex-add-label-environments "reftex-auc" "\
2424 Add label environment descriptions to `reftex-label-alist-style'.
2425 The format of ENTRY-LIST is exactly like `reftex-label-alist'. See there
2426 for details.
2427 This function makes it possible to support RefTeX from AUCTeX style files.
2428 The entries in ENTRY-LIST will be processed after the user settings in
2429 `reftex-label-alist', and before the defaults (specified in
2430 `reftex-default-label-alist-entries'). Any changes made to
2431 `reftex-label-alist-style' will raise a flag to the effect that
2432 the label information is recompiled on next use.
2434 \(fn ENTRY-LIST)" nil nil)
2436 (defalias 'reftex-add-to-label-alist 'reftex-add-label-environments)
2438 (autoload 'reftex-add-section-levels "reftex-auc" "\
2439 Add entries to the value of `reftex-section-levels'.
2440 The added values are kept local to the current document. The format
2441 of ENTRY-LIST is a list of cons cells (\"MACRONAME\" . LEVEL). See
2442 `reftex-section-levels' for an example.
2444 \(fn ENTRY-LIST)" nil nil)
2446 (autoload 'reftex-notice-new-section "reftex-auc" "\
2449 \(fn)" nil nil)
2451 ;;;***
2453 ;;;### (autoloads nil "reftex-cite" "reftex-cite.el" "5a53c260fa01268c04ea2f558add9d7d")
2454 ;;; Generated autoloads from reftex-cite.el
2456 (autoload 'reftex-default-bibliography "reftex-cite" "\
2457 Return the expanded value of variable `reftex-default-bibliography'.
2458 The expanded value is cached.
2460 \(fn)" nil nil)
2462 (autoload 'reftex-bib-or-thebib "reftex-cite" "\
2463 Test if BibTeX or \begin{thebibliography} should be used for the citation.
2464 Find the bof of the current file
2466 \(fn)" nil nil)
2468 (autoload 'reftex-get-bibfile-list "reftex-cite" "\
2469 Return list of bibfiles for current document.
2470 When using the chapterbib or bibunits package you should either
2471 use the same database files everywhere, or separate parts using
2472 different databases into different files (included into the mater file).
2473 Then this function will return the applicable database files.
2475 \(fn)" nil nil)
2477 (autoload 'reftex-pop-to-bibtex-entry "reftex-cite" "\
2478 Find BibTeX KEY in any file in FILE-LIST in another window.
2479 If MARK-TO-KILL is non-nil, mark new buffer to kill.
2480 If HIGHLIGHT is non-nil, highlight the match.
2481 If ITEM in non-nil, search for bibitem instead of database entry.
2482 If RETURN is non-nil, just return the entry and restore point.
2484 \(fn KEY FILE-LIST &optional MARK-TO-KILL HIGHLIGHT ITEM RETURN)" nil nil)
2486 (autoload 'reftex-end-of-bib-entry "reftex-cite" "\
2489 \(fn ITEM)" nil nil)
2491 (autoload 'reftex-parse-bibtex-entry "reftex-cite" "\
2492 Parse BibTeX ENTRY.
2493 If ENTRY is nil then parse the entry in current buffer between FROM and TO.
2494 If RAW is non-nil, keep double quotes/curly braces delimiting fields.
2496 \(fn ENTRY &optional FROM TO RAW)" nil nil)
2498 (autoload 'reftex-citation "reftex-cite" "\
2499 Make a citation using BibTeX database files.
2500 After prompting for a regular expression, scans the buffers with
2501 bibtex entries (taken from the \\bibliography command) and offers the
2502 matching entries for selection. The selected entry is formatted according
2503 to `reftex-cite-format' and inserted into the buffer.
2505 If NO-INSERT is non-nil, nothing is inserted, only the selected key returned.
2507 FORMAT-KEY can be used to pre-select a citation format.
2509 When called with a `C-u' prefix, prompt for optional arguments in
2510 cite macros. When called with a numeric prefix, make that many
2511 citations. When called with point inside the braces of a `\\cite'
2512 command, it will add another key, ignoring the value of
2513 `reftex-cite-format'.
2515 The regular expression uses an expanded syntax: && is interpreted as `and'.
2516 Thus, `aaaa&&bbb' matches entries which contain both `aaaa' and `bbb'.
2517 While entering the regexp, completion on knows citation keys is possible.
2518 `=' is a good regular expression to match all entries in all files.
2520 \(fn &optional NO-INSERT FORMAT-KEY)" t nil)
2522 (autoload 'reftex-citep "reftex-cite" "\
2523 Call `reftex-citation' with a format selector `?p'.
2525 \(fn)" t nil)
2527 (autoload 'reftex-citet "reftex-cite" "\
2528 Call `reftex-citation' with a format selector `?t'.
2530 \(fn)" t nil)
2532 (autoload 'reftex-make-cite-echo-string "reftex-cite" "\
2533 Format a bibtex ENTRY for the echo area and cache the result.
2535 \(fn ENTRY DOCSTRUCT-SYMBOL)" nil nil)
2537 (autoload 'reftex-create-bibtex-file "reftex-cite" "\
2538 Create a new BibTeX database BIBFILE with all entries referenced in document.
2539 The command prompts for a filename and writes the collected
2540 entries to that file. Only entries referenced in the current
2541 document with any \\cite-like macros are used. The sequence in
2542 the new file is the same as it was in the old database.
2544 Entries referenced from other entries must appear after all
2545 referencing entries.
2547 You can define strings to be used as header or footer for the
2548 created files in the variables `reftex-create-bibtex-header' or
2549 `reftex-create-bibtex-footer' respectively.
2551 \(fn BIBFILE)" t nil)
2553 ;;;***
2555 ;;;### (autoloads nil "reftex-dcr" "reftex-dcr.el" "08fc5bd6c35f9d6ab4a6ad336d3769c0")
2556 ;;; Generated autoloads from reftex-dcr.el
2558 (autoload 'reftex-view-crossref "reftex-dcr" "\
2559 View cross reference of macro at point. Point must be on the KEY
2560 argument. When at a `\\ref' macro, show corresponding `\\label'
2561 definition, also in external documents (`xr'). When on a label, show
2562 a locations where KEY is referenced. Subsequent calls find additional
2563 locations. When on a `\\cite', show the associated `\\bibitem' macro or
2564 the BibTeX database entry. When on a `\\bibitem', show a `\\cite' macro
2565 which uses this KEY. When on an `\\index', show other locations marked
2566 by the same index entry.
2567 To define additional cross referencing items, use the option
2568 `reftex-view-crossref-extra'. See also `reftex-view-crossref-from-bibtex'.
2569 With one or two C-u prefixes, enforce rescanning of the document.
2570 With argument 2, select the window showing the cross reference.
2571 AUTO-HOW is only for the automatic crossref display and is handed through
2572 to the functions `reftex-view-cr-cite' and `reftex-view-cr-ref'.
2574 \(fn &optional ARG AUTO-HOW FAIL-QUIETLY)" t nil)
2576 (autoload 'reftex-mouse-view-crossref "reftex-dcr" "\
2577 View cross reference of \\ref or \\cite macro where you click.
2578 If the macro at point is a \\ref, show the corresponding label definition.
2579 If it is a \\cite, show the BibTeX database entry.
2580 If there is no such macro at point, search forward to find one.
2581 With argument, actually select the window showing the cross reference.
2583 \(fn EV)" t nil)
2585 (autoload 'reftex-toggle-auto-view-crossref "reftex-dcr" "\
2586 Toggle the automatic display of crossref information in the echo area.
2587 When active, leaving point idle in the argument of a \\ref or \\cite macro
2588 will display info in the echo area.
2590 \(fn)" t nil)
2592 (autoload 'reftex-view-crossref-from-bibtex "reftex-dcr" "\
2593 View location in a LaTeX document which cites the BibTeX entry at point.
2594 Since BibTeX files can be used by many LaTeX documents, this function
2595 prompts upon first use for a buffer in RefTeX mode. To reset this
2596 link to a document, call the function with a prefix arg.
2597 Calling this function several times find successive citation locations.
2599 \(fn &optional ARG)" t nil)
2601 ;;;***
2603 ;;;### (autoloads nil "reftex-global" "reftex-global.el" "5fdd9c2edced0882471f86baf4b4b234")
2604 ;;; Generated autoloads from reftex-global.el
2606 (autoload 'reftex-create-tags-file "reftex-global" "\
2607 Create TAGS file by running `etags' on the current document.
2608 The TAGS file is also immediately visited with `visit-tags-table'.
2610 \(fn)" t nil)
2612 (autoload 'reftex-grep-document "reftex-global" "\
2613 Run grep query through all files related to this document.
2614 With prefix arg, force to rescan document.
2615 No active TAGS table is required.
2617 \(fn GREP-CMD)" t nil)
2619 (autoload 'reftex-search-document "reftex-global" "\
2620 Regexp search through all files of the current document.
2621 Starts always in the master file. Stops when a match is found.
2622 To continue searching for next match, use command \\[tags-loop-continue].
2623 No active TAGS table is required.
2625 \(fn &optional REGEXP)" t nil)
2627 (autoload 'reftex-query-replace-document "reftex-global" "\
2628 Do `query-replace-regexp' of FROM with TO over the entire document.
2629 Third arg DELIMITED (prefix arg) means replace only word-delimited matches.
2630 If you exit (\\[keyboard-quit], RET or q), you can resume the query replace
2631 with the command \\[tags-loop-continue].
2632 No active TAGS table is required.
2634 \(fn &optional FROM TO DELIMITED)" t nil)
2636 (autoload 'reftex-find-duplicate-labels "reftex-global" "\
2637 Produce a list of all duplicate labels in the document.
2639 \(fn)" t nil)
2641 (autoload 'reftex-change-label "reftex-global" "\
2642 Run `query-replace-regexp' of FROM with TO in all macro arguments.
2643 Works on the entire multifile document.
2644 If you exit (\\[keyboard-quit], RET or q), you can resume the query replace
2645 with the command \\[tags-loop-continue].
2646 No active TAGS table is required.
2648 \(fn &optional FROM TO)" t nil)
2650 (autoload 'reftex-renumber-simple-labels "reftex-global" "\
2651 Renumber all simple labels in the document to make them sequentially.
2652 Simple labels are the ones created by RefTeX, consisting only of the
2653 prefix and a number. After the command completes, all these labels will
2654 have sequential numbers throughout the document. Any references to
2655 the labels will be changed as well. For this, RefTeX looks at the
2656 arguments of any macros which either start or end in the string `ref'.
2657 This command should be used with care, in particular in multifile
2658 documents. You should not use it if another document refers to this
2659 one with the `xr' package.
2661 \(fn)" t nil)
2663 (autoload 'reftex-save-all-document-buffers "reftex-global" "\
2664 Save all documents associated with the current document.
2665 The function is useful after a global action like replacing or renumbering
2666 labels.
2668 \(fn)" t nil)
2670 (autoload 'reftex-isearch-minor-mode "reftex-global" "\
2671 When on, isearch searches the whole document, not only the current file.
2672 This minor mode allows isearch to search through all the files of
2673 the current TeX document.
2675 With no argument, this command toggles
2676 `reftex-isearch-minor-mode'. With a prefix argument ARG, turn
2677 `reftex-isearch-minor-mode' on if ARG is positive, otherwise turn it off.
2679 \(fn &optional ARG)" t nil)
2681 ;;;***
2683 ;;;### (autoloads nil "reftex-index" "reftex-index.el" "d80e84d499050e32569a454d8db16861")
2684 ;;; Generated autoloads from reftex-index.el
2686 (autoload 'reftex-index-selection-or-word "reftex-index" "\
2687 Put selection or the word near point into the default index macro.
2688 This uses the information in `reftex-index-default-macro' to make an index
2689 entry. The phrase indexed is the current selection or the word near point.
2690 When called with one `C-u' prefix, let the user have a chance to edit the
2691 index entry. When called with 2 `C-u' as prefix, also ask for the index
2692 macro and other stuff.
2693 When called inside TeX math mode as determined by the `texmathp.el' library
2694 which is part of AUCTeX, the string is first processed with the
2695 `reftex-index-math-format', which see.
2697 \(fn &optional ARG PHRASE)" t nil)
2699 (autoload 'reftex-index "reftex-index" "\
2700 Query for an index macro and insert it along with its arguments.
2701 The index macros available are those defined in `reftex-index-macro' or
2702 by a call to `reftex-add-index-macros', typically from an AUCTeX style file.
2703 RefteX provides completion for the index tag and the index key, and
2704 will prompt for other arguments.
2706 \(fn &optional CHAR KEY TAG SEL NO-INSERT)" t nil)
2708 (autoload 'reftex-index-complete-tag "reftex-index" "\
2711 \(fn &optional ITAG OPT-ARGS)" nil nil)
2713 (autoload 'reftex-index-select-tag "reftex-index" "\
2716 \(fn)" nil nil)
2718 (autoload 'reftex-index-complete-key "reftex-index" "\
2721 \(fn &optional TAG OPTIONAL INITIAL)" nil nil)
2723 (autoload 'reftex-index-show-entry "reftex-index" "\
2726 \(fn DATA &optional NO-REVISIT)" nil nil)
2728 (autoload 'reftex-display-index "reftex-index" "\
2729 Display a buffer with an index compiled from the current document.
2730 When the document has multiple indices, first prompts for the correct one.
2731 When index support is turned off, offer to turn it on.
2732 With one or two `C-u' prefixes, rescan document first.
2733 With prefix 2, restrict index to current document section.
2734 With prefix 3, restrict index to region.
2736 \(fn &optional TAG OVERRIDING-RESTRICTION REDO &rest LOCATIONS)" t nil)
2738 (autoload 'reftex-index-phrase-selection-or-word "reftex-index" "\
2739 Add current selection or word at point to the phrases buffer.
2740 When you are in transient-mark-mode and the region is active, the
2741 selection will be used - otherwise the word at point.
2742 You get a chance to edit the entry in the phrases buffer - finish with
2743 `C-c C-c'.
2745 \(fn ARG)" t nil)
2747 (autoload 'reftex-index-visit-phrases-buffer "reftex-index" "\
2748 Switch to the phrases buffer, initialize if empty.
2750 \(fn)" t nil)
2752 (autoload 'reftex-index-phrases-mode "reftex-index" "\
2753 Major mode for managing the Index phrases of a LaTeX document.
2754 This buffer was created with RefTeX.
2756 To insert new phrases, use
2757 - `C-c \\' in the LaTeX document to copy selection or word
2758 - `\\[reftex-index-new-phrase]' in the phrases buffer.
2760 To index phrases use one of:
2762 \\[reftex-index-this-phrase] index current phrase
2763 \\[reftex-index-next-phrase] index next phrase (or N with prefix arg)
2764 \\[reftex-index-all-phrases] index all phrases
2765 \\[reftex-index-remaining-phrases] index current and following phrases
2766 \\[reftex-index-region-phrases] index the phrases in the region
2768 You can sort the phrases in this buffer with \\[reftex-index-sort-phrases].
2769 To display information about the phrase at point, use \\[reftex-index-phrases-info].
2771 For more information see the RefTeX User Manual.
2773 Here are all local bindings.
2775 \\{reftex-index-phrases-mode-map}
2777 \(fn)" t nil)
2779 ;;;***
2781 ;;;### (autoloads nil "reftex-parse" "reftex-parse.el" "c327a848a6d168412b1a9be9f2e3dce8")
2782 ;;; Generated autoloads from reftex-parse.el
2784 (autoload 'reftex-parse-one "reftex-parse" "\
2785 Re-parse this file.
2787 \(fn)" t nil)
2789 (autoload 'reftex-parse-all "reftex-parse" "\
2790 Re-parse entire document.
2792 \(fn)" t nil)
2794 (autoload 'reftex-do-parse "reftex-parse" "\
2795 Do a document rescan.
2796 When allowed, do only a partial scan from FILE.
2798 \(fn RESCAN &optional FILE)" nil nil)
2800 (autoload 'reftex-everything-regexp "reftex-parse" "\
2803 \(fn)" nil nil)
2805 (autoload 'reftex-all-document-files "reftex-parse" "\
2806 Return a list of all files belonging to the current document.
2807 When RELATIVE is non-nil, give file names relative to directory
2808 of master file.
2810 \(fn &optional RELATIVE)" nil nil)
2812 (autoload 'reftex-locate-bibliography-files "reftex-parse" "\
2813 Scan buffer for bibliography macros and return file list.
2815 \(fn MASTER-DIR &optional FILES)" nil nil)
2817 (autoload 'reftex-section-info "reftex-parse" "\
2818 Return a section entry for the current match.
2819 Careful: This function expects the match-data to be still in place!
2821 \(fn FILE)" nil nil)
2823 (autoload 'reftex-ensure-index-support "reftex-parse" "\
2824 When index support is turned off, ask to turn it on and
2825 set the current prefix argument so that `reftex-access-scan-info'
2826 will rescan the entire document.
2828 \(fn &optional ABORT)" nil nil)
2830 (autoload 'reftex-index-info-safe "reftex-parse" "\
2833 \(fn FILE)" nil nil)
2835 (autoload 'reftex-index-info "reftex-parse" "\
2836 Return an index entry for the current match.
2837 Careful: This function expects the match-data to be still in place!
2839 \(fn FILE)" nil nil)
2841 (autoload 'reftex-short-context "reftex-parse" "\
2842 Get about one line of useful context for the label definition at point.
2844 \(fn ENV PARSE &optional BOUND DERIVE)" nil nil)
2846 (autoload 'reftex-where-am-I "reftex-parse" "\
2847 Return the docstruct entry above point.
2848 Actually returns a cons cell in which the cdr is a flag indicating
2849 if the information is exact (t) or approximate (nil).
2851 \(fn)" nil nil)
2853 (autoload 'reftex-notice-new "reftex-parse" "\
2854 Hook to handshake with RefTeX after something new has been inserted.
2856 \(fn &optional N FORCE)" nil nil)
2858 (autoload 'reftex-what-macro-safe "reftex-parse" "\
2859 Call `reftex-what-macro' with special syntax table.
2861 \(fn WHICH &optional BOUND)" nil nil)
2863 (autoload 'reftex-what-macro "reftex-parse" "\
2864 Find out if point is within the arguments of any TeX-macro.
2865 The return value is either (\"\\macro\" . (point)) or a list of them.
2867 If WHICH is nil, immediately return nil.
2868 If WHICH is 1, return innermost enclosing macro.
2869 If WHICH is t, return list of all macros enclosing point.
2870 If WHICH is a list of macros, look only for those macros and return the
2871 name of the first macro in this list found to enclose point.
2872 If the optional BOUND is an integer, bound backwards directed
2873 searches to this point. If it is nil, limit to nearest \\section -
2874 like statement.
2876 This function is pretty stable, but can be fooled if the text contains
2877 things like \\macro{aa}{bb} where \\macro is defined to take only one
2878 argument. As RefTeX cannot know this, the string \"bb\" would still be
2879 considered an argument of macro \\macro.
2881 \(fn WHICH &optional BOUND)" nil nil)
2883 (autoload 'reftex-what-environment "reftex-parse" "\
2884 Find out if point is inside a LaTeX environment.
2885 The return value is (e.g.) either (\"equation\" . (point)) or a list of
2886 them.
2888 If WHICH is nil, immediately return nil.
2889 If WHICH is 1, return innermost enclosing environment.
2890 If WHICH is t, return list of all environments enclosing point.
2891 If WHICH is a list of environments, look only for those environments and
2892 return the name of the first environment in this list found to enclose
2893 point.
2895 If the optional BOUND is an integer, bound backwards directed searches to
2896 this point. If it is nil, limit to nearest \\section - like statement.
2898 \(fn WHICH &optional BOUND)" nil nil)
2900 (autoload 'reftex-what-special-env "reftex-parse" "\
2901 Run the special environment parsers and return the matches.
2903 The return value is (e.g.) either (\"my-parser-function\" . (point))
2904 or a list of them.
2906 If WHICH is nil, immediately return nil.
2907 If WHICH is 1, return innermost enclosing environment.
2908 If WHICH is t, return list of all environments enclosing point.
2909 If WHICH is a list of environments, look only for those environments and
2910 return the name of the first environment in this list found to enclose
2911 point.
2913 \(fn WHICH &optional BOUND)" nil nil)
2915 (autoload 'reftex-nth-arg "reftex-parse" "\
2916 Return the Nth following {} or [] parentheses content.
2917 OPT-ARGS is a list of argument numbers which are optional.
2919 \(fn N &optional OPT-ARGS)" nil nil)
2921 (autoload 'reftex-move-over-touching-args "reftex-parse" "\
2924 \(fn)" nil nil)
2926 (autoload 'reftex-init-section-numbers "reftex-parse" "\
2927 Initialize the section numbers with zeros or with what is found in the TOC-ENTRY.
2929 \(fn &optional TOC-ENTRY APPENDIX)" nil nil)
2931 (autoload 'reftex-section-number "reftex-parse" "\
2932 Return a string with the current section number.
2933 When LEVEL is non-nil, increase section numbers on that level.
2935 \(fn &optional LEVEL STAR)" nil nil)
2937 ;;;***
2939 ;;;### (autoloads nil "reftex-ref" "reftex-ref.el" "64cd7a4eaec426177a8fb3689139d935")
2940 ;;; Generated autoloads from reftex-ref.el
2942 (autoload 'reftex-label-location "reftex-ref" "\
2943 Return the environment or macro which determines the label type at point.
2944 If optional BOUND is an integer, limit backward searches to that point.
2946 \(fn &optional BOUND)" nil nil)
2948 (autoload 'reftex-label-info-update "reftex-ref" "\
2951 \(fn CELL)" nil nil)
2953 (autoload 'reftex-label-info "reftex-ref" "\
2956 \(fn LABEL &optional FILE BOUND DERIVE ENV-OR-MAC)" nil nil)
2958 (autoload 'reftex-label "reftex-ref" "\
2959 Insert a unique label. Return the label.
2960 If ENVIRONMENT is given, don't bother to find out yourself.
2961 If NO-INSERT is non-nil, do not insert label into buffer.
2962 With prefix arg, force to rescan document first.
2963 When you are prompted to enter or confirm a label, and you reply with
2964 just the prefix or an empty string, no label at all will be inserted.
2965 A new label is also recorded into the label list.
2966 This function is controlled by the settings of reftex-insert-label-flags.
2968 \(fn &optional ENVIRONMENT NO-INSERT)" t nil)
2970 (autoload 'reftex-reference "reftex-ref" "\
2971 Make a LaTeX reference. Look only for labels of a certain TYPE.
2972 With prefix arg, force to rescan buffer for labels. This should only be
2973 necessary if you have recently entered labels yourself without using
2974 reftex-label. Rescanning of the buffer can also be requested from the
2975 label selection menu.
2976 The function returns the selected label or nil.
2977 If NO-INSERT is non-nil, do not insert \\ref command, just return label.
2978 When called with 2 C-u prefix args, disable magic word recognition.
2980 \(fn &optional TYPE NO-INSERT CUT)" t nil)
2982 (autoload 'reftex-query-label-type "reftex-ref" "\
2985 \(fn)" nil nil)
2987 (autoload 'reftex-show-label-location "reftex-ref" "\
2990 \(fn DATA FORWARD NO-REVISIT &optional STAY ERROR)" nil nil)
2992 (autoload 'reftex-goto-label "reftex-ref" "\
2993 Prompt for a label (with completion) and jump to the location of this label.
2994 Optional prefix argument OTHER-WINDOW goes to the label in another window.
2996 \(fn &optional OTHER-WINDOW)" t nil)
2998 ;;;***
3000 ;;;### (autoloads nil "reftex-sel" "reftex-sel.el" "faea36cbe37033efd3f9063187eef7ee")
3001 ;;; Generated autoloads from reftex-sel.el
3003 (autoload 'reftex-select-label-mode "reftex-sel" "\
3004 Major mode for selecting a label in a LaTeX document.
3005 This buffer was created with RefTeX.
3006 It only has a meaningful keymap when you are in the middle of a
3007 selection process.
3008 To select a label, move the cursor to it and press RET.
3009 Press `?' for a summary of important key bindings.
3011 During a selection process, these are the local bindings.
3013 \\{reftex-select-label-mode-map}
3015 \(fn)" t nil)
3017 (autoload 'reftex-select-bib-mode "reftex-sel" "\
3018 Major mode for selecting a citation key in a LaTeX document.
3019 This buffer was created with RefTeX.
3020 It only has a meaningful keymap when you are in the middle of a
3021 selection process.
3022 In order to select a citation, move the cursor to it and press RET.
3023 Press `?' for a summary of important key bindings.
3025 During a selection process, these are the local bindings.
3027 \\{reftex-select-label-mode-map}
3029 \(fn)" t nil)
3031 (autoload 'reftex-get-offset "reftex-sel" "\
3034 \(fn BUF HERE-AM-I &optional TYPEKEY TOC INDEX FILE)" nil nil)
3036 (autoload 'reftex-insert-docstruct "reftex-sel" "\
3039 \(fn BUF TOC LABELS INDEX-ENTRIES FILES CONTEXT COUNTER SHOW-COMMENTED HERE-I-AM XR-PREFIX TOC-BUFFER)" nil nil)
3041 (autoload 'reftex-find-start-point "reftex-sel" "\
3044 \(fn FALLBACK &rest LOCATIONS)" nil nil)
3046 (autoload 'reftex-select-item "reftex-sel" "\
3049 \(fn REFTEX-SELECT-PROMPT HELP-STRING KEYMAP &optional OFFSET CALL-BACK CB-FLAG)" nil nil)
3051 ;;;***
3053 ;;;### (autoloads nil "reftex-toc" "reftex-toc.el" "e04344fac7ba4c2043439e130bdd283f")
3054 ;;; Generated autoloads from reftex-toc.el
3056 (autoload 'reftex-toc "reftex-toc" "\
3057 Show the table of contents for the current document.
3058 When called with a raw C-u prefix, rescan the document first.
3060 \(fn &optional REBUILD REUSE)" t nil)
3062 (autoload 'reftex-toc-recenter "reftex-toc" "\
3063 Display the TOC window and highlight line corresponding to current position.
3065 \(fn &optional ARG)" t nil)
3067 (autoload 'reftex-toggle-auto-toc-recenter "reftex-toc" "\
3068 Toggle the automatic recentering of the TOC window.
3069 When active, leaving point idle will make the TOC window jump to the correct
3070 section.
3072 \(fn)" t nil)
3074 ;;;***
3076 ;;; End of automatically extracted autoloads.
3078 (provide 'reftex)
3080 ;;; reftex.el ends here