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