Merge from standalone RefTeX repository.
[bpt/emacs.git] / lisp / textmodes / reftex-vars.el
CommitLineData
3afbc435 1;;; reftex-vars.el --- configuration variables for RefTeX
d5a2f2b0 2
acaf905b 3;; Copyright (C) 1997-1999, 2001-2012 Free Software Foundation, Inc.
3ba2590f 4
6fbeb429 5;; Author: Carsten Dominik <dominik@science.uva.nl>
ce545621 6;; Maintainer: auctex-devel@gnu.org
3ba2590f
RS
7
8;; This file is part of GNU Emacs.
9
1fecc8fe 10;; GNU Emacs is free software: you can redistribute it and/or modify
3ba2590f 11;; it under the terms of the GNU General Public License as published by
1fecc8fe
GM
12;; the Free Software Foundation, either version 3 of the License, or
13;; (at your option) any later version.
3ba2590f
RS
14
15;; GNU Emacs is distributed in the hope that it will be useful,
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
1fecc8fe 17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3ba2590f
RS
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
1fecc8fe 21;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
1a9461d0 22
3afbc435
PJ
23;;; Commentary:
24
25;;; Code:
0c86715d 26(defvar reftex-tables-dirty)
7c4d13cc 27(eval-when-compile (require 'cl))
f541b8c6
MR
28(eval-and-compile
29 (defun reftex-set-dirty (symbol value)
30 (setq reftex-tables-dirty t)
31 (set symbol value)))
1a9461d0
CD
32
33;; Define the two constants which are needed during compilation
34
35(eval-and-compile
36(defconst reftex-label-alist-builtin
37 '(
38 ;; Some aliases, mostly for backward compatibility
39 (Sideways "Alias for -->rotating" (rotating))
40 (AMSTeX "amsmath with eqref macro"
41 ((nil ?e nil "~\\eqref{%s}")
42 amsmath))
43
44 ;; Individual package defaults
45 (amsmath "AMS-LaTeX math environments"
46 (("align" ?e nil nil eqnarray-like)
47 ("gather" ?e nil nil eqnarray-like)
48 ("multline" ?e nil nil t)
49 ("flalign" ?e nil nil eqnarray-like)
50 ("alignat" ?e nil nil alignat-like)
51 ("xalignat" ?e nil nil alignat-like)
52 ("xxalignat" ?e nil nil alignat-like)
53 ("subequations" ?e nil nil t)))
54
55 (endnotes "The \\endnote macro"
56 (("\\endnote[]{}" ?N "en:" "~\\ref{%s}" 2
57 (regexp "endnotes?" "notes?" "Anmerkung\\(en\\)?" "Anm\\."))))
58
59 (fancybox "The Beqnarray environment"
60 (("Beqnarray" ?e nil nil eqnarray-like)))
61
62 (floatfig "The floatingfigure environment"
63 (("floatingfigure" ?f nil nil caption)))
64
65 (longtable "The longtable environment"
66 (("longtable" ?t nil nil caption)))
67
68 (picinpar "The figwindow and tabwindow environments"
69 (("figwindow" ?f nil nil 1)
70 ("tabwindow" ?f nil nil 1)))
71
72 (rotating "Sidewaysfigure and table"
73 (("sidewaysfigure" ?f nil nil caption)
74 ("sidewaystable" ?t nil nil caption)))
75
76 (sidecap "CSfigure and SCtable"
77 (("SCfigure" ?f nil nil caption)
78 ("SCtable" ?t nil nil caption)))
79
80 (subfigure "Subfigure environments/macro"
81 (("subfigure" ?f nil nil caption)
82 ("subfigure*" ?f nil nil caption)
83 ("\\subfigure[]{}" ?f nil nil 1)))
84
85 (supertab "Supertabular environment"
86 (("supertabular" ?t nil nil "\\tablecaption{")))
87
88 (wrapfig "The wrapfigure environment"
89 (("wrapfigure" ?f nil nil caption)))
90
cfcc9cc8 91 (ctable "The ctable package"
983741d8 92 (("\\ctable[]{}{}{}" ?t "tab:" "\\ref{%s}" 1 ("table" "Tabelle"))))
cfcc9cc8
TH
93
94 (listings "The listings package"
983741d8 95 (("lstlisting" ?l "lst:" "~\\ref{%s}" nil (regexp "[Ll]isting"))))
cfcc9cc8
TH
96
97 (minted "The minted package"
983741d8 98 (("minted" ?l "lst:" "~\\ref{%s}" nil (regexp "[Ll]isting"))))
cfcc9cc8 99
1a9461d0
CD
100 ;; The LaTeX core stuff
101 (LaTeX "LaTeX default environments"
102 (("section" ?s "%S" "~\\ref{%s}" (nil . t)
103 (regexp "parts?" "chapters?" "chap\\." "sections?" "sect?\\."
3666daf6
CD
104 "paragraphs?" "par\\."
105 "\\\\S" "\247" "Teile?" "Kapitel" "Kap\\." "Abschnitte?"
106 "appendi\\(x\\|ces\\)" "App\\." "Anh\"?ange?" "Anh\\."))
1a9461d0
CD
107
108 ("enumerate" ?i "item:" "~\\ref{%s}" item
109 (regexp "items?" "Punkte?"))
c8de140b 110
1a9461d0
CD
111 ("equation" ?e "eq:" "~(\\ref{%s})" t
112 (regexp "equations?" "eqs?\\." "eqn\\." "Gleichung\\(en\\)?" "Gl\\."))
113 ("eqnarray" ?e "eq:" nil eqnarray-like)
c8de140b 114
1a9461d0
CD
115 ("figure" ?f "fig:" "~\\ref{%s}" caption
116 (regexp "figure?[sn]?" "figs?\\." "Abbildung\\(en\\)?" "Abb\\."))
117 ("figure*" ?f nil nil caption)
c8de140b 118
1a9461d0
CD
119 ("table" ?t "tab:" "~\\ref{%s}" caption
120 (regexp "tables?" "tab\\." "Tabellen?"))
121 ("table*" ?t nil nil caption)
c8de140b 122
1a9461d0
CD
123 ("\\footnote[]{}" ?n "fn:" "~\\ref{%s}" 2
124 (regexp "footnotes?" "Fussnoten?"))
c8de140b 125
1a9461d0
CD
126 ("any" ?\ " " "~\\ref{%s}" nil)
127
128 ;; The label macro is hard coded, but it *could* be defined like this:
129 ;;("\\label{*}" nil nil nil nil)
cfcc9cc8 130 )))
1a9461d0
CD
131 "The default label environment descriptions.
132Lower-case symbols correspond to a style file of the same name in the LaTeX
133distribution. Mixed-case symbols are convenience aliases.")
134
135(defconst reftex-cite-format-builtin
136 '((default "Default macro \\cite{%l}"
f3c18bd0 137 "\\cite[]{%l}")
1a9461d0 138 (natbib "The Natbib package"
f3c18bd0
CD
139 ((?\C-m . "\\cite[][]{%l}")
140 (?t . "\\citet[][]{%l}")
141 (?T . "\\citet*[][]{%l}")
142 (?p . "\\citep[][]{%l}")
143 (?P . "\\citep*[][]{%l}")
1a9461d0
CD
144 (?e . "\\citep[e.g.][]{%l}")
145 (?s . "\\citep[see][]{%l}")
146 (?a . "\\citeauthor{%l}")
147 (?A . "\\citeauthor*{%l}")
6fbeb429
CD
148 (?y . "\\citeyear{%l}")
149 (?n . "\\nocite{%l}")))
3666daf6
CD
150 (amsrefs "The AMSRefs package"
151 ((?\C-m . "\\cite{%l}")
152 (?p . "\\cite{%l}")
153 (?P . "\\cites{%l}")
154 (?t . "\\ocite{%l}")
155 (?T . "\\ocites{%l}")
156 (?y . "\\ycite{%l}")
157 (?Y . "\\ycites{%l}")
158 (?a . "\\citeauthor{%l}")
159 (?A . "\\citeauthory{%l}")
160 (?f . "\\fullcite{%l}")
161 (?F . "\\fullocite{%l}")
162 (?n . "\\nocite{%l}")))
3a1e8128
CD
163 (jurabib "The Jurabib package"
164 ((?\C-m . "\\cite{%l}")
165 (?c . "\\cite[][]{%l}")
166 (?t . "\\citet{%l}")
167 (?p . "\\citep{%l}")
168 (?e . "\\citep[e.g.][]{%l}")
169 (?s . "\\citep[see][]{%l}")
170 (?u . "\\fullcite{%l}")
171 (?i . "\\citetitle{%l}")
172 (?a . "\\citeauthor{%l}")
173 (?e . "\\citefield{}{%l}")
174 (?y . "\\citeyear{%l}")
175 (?f . "\\footcite{%l}")
176 (?F . "\\footcite[][]{%l}")
177 (?l . "\\footfullcite{%l}")))
d8fb2015
CD
178 (bibentry "The Bibentry package"
179 "\\bibentry{%l}")
1a9461d0 180 (harvard "The Harvard package"
f3c18bd0
CD
181 ((?\C-m . "\\cite[]{%l}")
182 (?p . "\\cite[]{%l}")
1a9461d0
CD
183 (?t . "\\citeasnoun{%l}")
184 (?n . "\\citeasnoun{%l}")
185 (?s . "\\possessivecite{%l}")
186 (?e . "\\citeaffixed{%l}{?}")
187 (?y . "\\citeyear{%l}")
188 (?a . "\\citename{%l}")))
189 (chicago "The Chicago package"
f3c18bd0
CD
190 ((?\C-m . "\\cite[]{%l}")
191 (?t . "\\citeN[]{%l}")
1a9461d0 192 (?T . "\\shortciteN{%l}")
f3c18bd0 193 (?p . "\\cite[]{%l}")
1a9461d0
CD
194 (?P . "\\shortcite{%l}")
195 (?a . "\\citeA{%l}")
196 (?A . "\\shortciteA{%l}")
197 (?y . "\\citeyear{%l}")))
198 (astron "The Astron package"
f3c18bd0
CD
199 ((?\C-m . "\\cite[]{%l}")
200 (?p . "\\cite[]{%l}" )
1a9461d0
CD
201 (?t . "%2a (\\cite{%l})")))
202 (author-year "Do-it-yourself Author-year"
203 ((?\C-m . "\\cite{%l}")
204 (?t . "%2a (%y)\\nocite{%l}")
205 (?p . "(%2a %y\\nocite{%l})")))
206 (locally "Full info in parenthesis"
207 "(%2a %y, %j %v, %P, %e: %b, %u, %s %<)")
4f595e15
RA
208 (context
209 "ConTeXt bib module"
210 ((?\C-m . "\\cite[%l]")
211 (?s . "\\cite[][%l]")
212 (?n . "\\nocite[%l]")))
1a9461d0
CD
213 )
214 "Builtin versions of the citation format.
215The following conventions are valid for all alist entries:
216`?\C-m' should always point to a straight \\cite{%l} macro.
217`?t' should point to a textual citation (citation as a noun).
218`?p' should point to a parenthetical citation.")
219
c8de140b 220(defconst reftex-index-macros-builtin
1a9461d0 221 '((default "Default \\index and \\glossary macros"
7c4d13cc
CD
222 (("\\index{*}" "idx" ?i "" nil t)
223 ("\\glossary{*}" "glo" ?g "" nil t)))
1a9461d0 224 (multind "The multind.sty package"
7c4d13cc 225 (("\\index{}{*}" 1 ?i "" nil t)))
1a9461d0 226 (index "The index.sty package"
3666daf6
CD
227 (("\\index[]{*}" 1 ?i "" nil t)
228 ("\\index*[]{*}" 1 ?I "" nil nil)))
1a9461d0 229 (Index-Shortcut "index.sty with \\shortindexingon"
7c4d13cc 230 (("\\index[]{*}" 1 ?i "" nil t)
3666daf6 231 ("\\index*[]{*}" 1 ?I "" nil nil)
c8de140b 232 ("^[]{*}" 1 ?^ "" texmathp t)
3666daf6 233 ("_[]{*}" 1 ?_ "" texmathp nil))))
c8de140b 234 "Builtin stuff for `reftex-index-macros'.
1a9461d0
CD
235Lower-case symbols correspond to a style file of the same name in the LaTeX
236distribution. Mixed-case symbols are convenience aliases.")
237)
238
239;; Configuration Variables and User Options for RefTeX ------------------
240
241(defgroup reftex nil
242 "LaTeX label and citation support."
243 :tag "RefTeX"
c8de140b 244 :link '(url-link :tag "Home Page"
4f595e15 245 "http://www.gnu.org/software/auctex/reftex.html")
1a9461d0
CD
246 :link '(emacs-commentary-link :tag "Commentary in reftex.el" "reftex.el")
247 :link '(custom-manual "(reftex)Top")
248 :prefix "reftex-"
249 :group 'tex)
250
6fbeb429 251
1a9461d0
CD
252;; Table of contents configuration --------------------------------------
253
254(defgroup reftex-table-of-contents-browser nil
255 "A multifile table of contents browser."
256 :group 'reftex)
257
6fbeb429
CD
258(defcustom reftex-include-file-commands '("include" "input")
259 "LaTeX commands which input another file.
260The file name is expected after the command, either in braces or separated
261by whitespace."
262 :group 'reftex-table-of-contents-browser
263 :type '(repeat string))
264
265(defcustom reftex-max-section-depth 12
266 "Maximum depth of section levels in document structure.
4f595e15
RA
267The default in standard LaTeX is 7, but there are packages for
268which this needs to be larger."
6fbeb429
CD
269 :group 'reftex-table-of-contents-browser
270 :type 'integer)
271
272;; LaTeX section commands and level numbers
273(defcustom reftex-section-levels
274 '(
275 ("part" . 0)
276 ("chapter" . 1)
277 ("section" . 2)
278 ("subsection" . 3)
279 ("subsubsection" . 4)
280 ("paragraph" . 5)
281 ("subparagraph" . 6)
6fbeb429
CD
282 ("addchap" . -1) ; KOMA-Script
283 ("addsec" . -2) ; KOMA-Script
284;;; ("minisec" . -7) ; KOMA-Script
285 )
286 "Commands and levels used for defining sections in the document.
287This is an alist with each element like (COMMAND-NAME . LEVEL).
288The car of each cons cell is the name of the section macro (without
289the backslash). The cdr is a number indicating its level. A negative
290level means the same level as the positive value, but the section will
291never get a number. The cdr may also be a function which will be called
3666daf6 292to after the section-re matched to determine the level.
c8de140b 293This list is also used for promotion and demotion of sectioning commands.
3666daf6
CD
294If you are using a document class which has several sets of sectioning
295commands, promotion only works correctly if this list is sorted first
296by set, then within each set by level. The promotion commands always
297select the nearest entry with the correct new level."
6fbeb429
CD
298 :group 'reftex-table-of-contents-browser
299 :set 'reftex-set-dirty
300 :type '(repeat
301 (cons (string :tag "sectioning macro" "")
3666daf6
CD
302 (choice
303 (number :tag "level " 0)
304 (symbol :tag "function " my-level-func)))))
6fbeb429 305
7c4d13cc 306(defcustom reftex-toc-max-level 100
fb7ada5f 307 "The maximum level of toc entries which will be included in the TOC.
7c4d13cc
CD
308Section headings with a bigger level will be ignored. In RefTeX, chapters
309are level 1, sections are level 2 etc.
310This variable can be changed from within the *toc* buffer with the `t' key."
311 :group 'reftex-table-of-contents-browser
312 :type 'integer)
313
3b919c9f 314(defcustom reftex-part-resets-chapter nil
fb7ada5f 315 "Non-nil means, \\part is like any other sectioning command.
3b919c9f
CD
316This means, part numbers will be included in the numbering of chapters, and
317chapter counters will be reset for each part.
318When nil (the default), parts are special, do not reset the chapter counter
319and also do not show up in chapter numbers."
320 :group 'reftex-table-of-contents-browser
321 :type 'boolean)
322
323
3666daf6 324(defcustom reftex-auto-recenter-toc 'frame
fb7ada5f 325 "Non-nil means, turn automatic recentering of *TOC* window on.
3666daf6 326When active, the *TOC* window will always show the section you
3b919c9f
CD
327are currently working in. Recentering happens whenever Emacs is idle for
328more than `reftex-idle-time' seconds.
3b919c9f 329
3666daf6 330Value t means, turn on immediately when RefTeX gets started. Then,
c8de140b 331recentering will work for any TOC window created during the session.
3666daf6
CD
332
333Value 'frame (the default) means, turn automatic recentering on only while the
334dedicated TOC frame does exist, and do the recentering only in that frame. So
4f595e15 335when creating that frame (with `d' key in an ordinary TOC window), the
3666daf6
CD
336automatic recentering is turned on. When the frame gets destroyed, automatic
337recentering is turned off again.
338
c8de140b 339This feature can be turned on and off from the menu
3666daf6
CD
340\(Ref->Options)."
341 :group 'reftex-table-of-contents-browser
342 :type '(choice
343 (const :tag "never" nil)
344 (const :tag "always" t)
23fed453 345 (const :tag "in dedicated frame only" frame)))
c8de140b 346
6fbeb429 347(defcustom reftex-toc-split-windows-horizontally nil
fb7ada5f 348 "Non-nil means, create TOC window by splitting window horizontally."
6fbeb429
CD
349 :group 'reftex-table-of-contents-browser
350 :type 'boolean)
351
3666daf6 352(defcustom reftex-toc-split-windows-fraction .3
fb7ada5f 353 "Fraction of the width or height of the frame to be used for TOC window.
3666daf6 354See also `reftex-toc-split-windows-horizontally'."
6fbeb429
CD
355 :group 'reftex-table-of-contents-browser
356 :type 'number)
357
3666daf6
CD
358(defvar reftex-toc-split-windows-horizontally-fraction 0.5
359 "This variable is obsolete, use `reftex-toc-split-windows-fraction' instead.")
360
1a9461d0 361(defcustom reftex-toc-keep-other-windows t
fb7ada5f 362 "Non-nil means, split the selected window to display the *toc* buffer.
1a9461d0
CD
363This helps to keep the window configuration, but makes the *toc* small.
364When nil, all other windows except the selected one will be deleted, so
365that the *toc* window fills half the frame."
366 :group 'reftex-table-of-contents-browser
367 :type 'boolean)
368
369(defcustom reftex-toc-include-file-boundaries nil
fb7ada5f 370 "Non-nil means, include file boundaries in *toc* buffer.
1a9461d0
CD
371This flag can be toggled from within the *toc* buffer with the `F' key."
372 :group 'reftex-table-of-contents-browser
373 :type 'boolean)
374
375(defcustom reftex-toc-include-labels nil
fb7ada5f 376 "Non-nil means, include labels in *toc* buffer.
1a9461d0
CD
377This flag can be toggled from within the *toc* buffer with the `l' key."
378 :group 'reftex-table-of-contents-browser
379 :type 'boolean)
380
381(defcustom reftex-toc-include-index-entries nil
fb7ada5f 382 "Non-nil means, include index entries in *toc* buffer.
1a9461d0
CD
383This flag can be toggled from within the *toc* buffer with the `i' key."
384 :group 'reftex-table-of-contents-browser
385 :type 'boolean)
386
3666daf6 387(defcustom reftex-toc-confirm-promotion 2
fb7ada5f 388 "Non-nil means, promotion/demotion commands first prompt for confirmation.
4f595e15
RA
389If nil, the command is executed immediately. If this is an integer N,
390ask for confirmation only if N or more section commands are going to be
3666daf6
CD
391changed."
392 :group 'reftex-table-of-contents-browser
393 :type '(choice
394 (const :tag "Never" nil)
395 (const :tag "Always" t)
396 (number :tag "When more than N sections" :value 2)))
397
1a9461d0 398(defcustom reftex-toc-include-context nil
fb7ada5f 399 "Non-nil means, include context with labels in the *toc* buffer.
1a9461d0
CD
400Context will only be shown when labels are visible as well.
401This flag can be toggled from within the *toc* buffer with the `c' key."
402 :group 'reftex-table-of-contents-browser
403 :type 'boolean)
404
405(defcustom reftex-toc-follow-mode nil
fb7ada5f 406 "Non-nil means, point in *toc* buffer will cause other window to follow.
1a9461d0
CD
407The other window will show the corresponding part of the document.
408This flag can be toggled from within the *toc* buffer with the `f' key."
409 :group 'reftex-table-of-contents-browser
410 :type 'boolean)
411
412(defcustom reftex-revisit-to-follow nil
fb7ada5f 413 "Non-nil means, follow-mode will revisit files if necessary.
4f595e15 414If nil, follow-mode will be suspended for stuff in unvisited files."
1a9461d0
CD
415 :group 'reftex-table-of-contents-browser
416 :group 'reftex-referencing-labels
417 :type 'boolean)
418
419(defcustom reftex-toc-mode-hook nil
c8de140b 420 "Mode hook for `reftex-toc-mode'."
1a9461d0
CD
421 :group 'reftex-table-of-contents-browser
422 :type 'hook)
423
424;; Label Support Configuration
425
426(defgroup reftex-label-support nil
427 "Support for creation, insertion and referencing of labels in LaTeX."
428 :group 'reftex)
429
430(defgroup reftex-defining-label-environments nil
431 "Definition of environments and macros to do with label."
432 :group 'reftex-label-support)
433
434(defcustom reftex-default-label-alist-entries
435 '(amsmath endnotes fancybox floatfig longtable picinpar
cfcc9cc8
TH
436 rotating sidecap subfigure supertab wrapfig
437 listings minted ctable LaTeX)
1a9461d0 438 "Default label alist specifications. LaTeX should always be the last entry.
c8de140b 439The value of this variable is a list of symbols with associations in the
1a9461d0
CD
440constant `reftex-label-alist-builtin'. Check that constant for a full list
441of options."
442 :group 'reftex-defining-label-environments
443 :set 'reftex-set-dirty
444 :type `(set
3666daf6 445 :indent 4
1a9461d0
CD
446 :inline t
447 :greedy t
448 ,@(mapcar
3666daf6
CD
449 (lambda (x)
450 (list 'const :tag (concat (symbol-name (nth 0 x))
451 ": " (nth 1 x))
452 (nth 0 x)))
1a9461d0
CD
453 reftex-label-alist-builtin)))
454
455(defcustom reftex-label-alist nil
456 "Alist with information on environments for \\label-\\ref use.
457
4f595e15
RA
458This doc string is easier to understand after reading the configuration
459examples in the manual. Looking at the builtin defaults in the constant
1a9461d0
CD
460`reftex-label-alist-builtin' may also be instructive.
461
462Set this variable to define additions and changes to the default. The only
463things you MUST NOT change is that `?s' is the type indicator for section
464labels, and SPC for the `any' label type. These are hard-coded at other
465places in the code.
466
467The value of the variable must be a list of items. Each item is a list
468itself and has the following structure:
469
470 (ENV-OR-MACRO TYPE-KEY LABEL-PREFIX REFERENCE-FORMAT CONTEXT-METHOD
7c4d13cc 471 (MAGIC-WORD ... ) TOC-LEVEL)
1a9461d0
CD
472
473Each list entry describes either an environment carrying a counter for use
474with \\label and \\ref, or a LaTeX macro defining a label as (or inside)
475one of its arguments. The elements of each list entry are:
476
477ENV-OR-MACRO
478 Name of the environment (like \"table\") or macro (like \"\\\\myfig\").
479 For macros, indicate the macro arguments for best results, as in
480 \"\\\\myfig[]{}{}{*}{}\". Use square brackets for optional arguments,
481 a star to mark the label argument, if any. The macro does not have to
482 have a label argument - you could also use \\label{..} inside one of
483 its arguments.
484 Special names: `section' for section labels, `any' to define a group
485 which contains all labels.
486
4f595e15
RA
487 This may also be a function to do local parsing and identify point to
488 be in a non-standard label environment. The function must take an
489 argument BOUND and limit backward searches to this value. It should
490 return either nil or the position where the special environment starts.
491 See the Info documentation for an example.
1a9461d0
CD
492
493 Finally this may also be nil if the entry is only meant to change
494 some settings associated with the type indicator character (see below).
495
496TYPE-KEY
497 Type indicator character, like `?t', must be a printable ASCII character.
498 The type indicator is a single character which defines a label type.
499 Any label inside the environment or macro is assumed to belong to this
500 type. The same character may occur several times in this list, to cover
501 cases in which different environments carry the same label type (like
502 `equation' and `eqnarray').
503 If the type indicator is nil and the macro has a label argument {*},
70d797cd 504 the macro defines neutral labels just like \\label. In this case
4f595e15 505 the remainder of this entry is ignored.
1a9461d0
CD
506
507LABEL-PREFIX
508 Label prefix string, like \"tab:\".
509 The prefix is a short string used as the start of a label. It may be the
510 empty string. The prefix may contain the following `%' escapes:
511 %f Current file name with directory and extension stripped.
512 %F Current file name relative to directory of master file.
f3c18bd0
CD
513 %m Master file name, directory and extension stripped.
514 %M Directory name (without path) where master file is located.
1a9461d0
CD
515 %u User login name, on systems which support this.
516 %S A section prefix derived with variable `reftex-section-prefixes'.
517
518 Example: In a file `intro.tex', \"eq:%f:\" will become \"eq:intro:\").
519
520REFERENCE-FORMAT
4f595e15
RA
521 Format string for reference insertion in buffer. `%s' will be replaced
522 by the label.
1a9461d0
CD
523 When the format starts with `~', the `~' will only be inserted if
524 there is not already a whitespace before point.
525
526CONTEXT-METHOD
527 Indication on how to find the short context.
528 - If nil, use the text following the \\label{...} macro.
529 - If t, use
530 - the section heading for section labels.
531 - text following the \\begin{...} statement of environments.
532 (not a good choice for environments like eqnarray or enumerate,
533 where one has several labels in a single environment).
534 - text after the macro name (starting with the first arg) for macros.
535 - If an integer, use the nth argument of the macro. As a special case,
536 1000 means to get text after the last macro argument.
537 - If a string, use as regexp to search *backward* from the label. Context
4f595e15 538 is then the text following the end of the match. E.g. setting this to
1a9461d0
CD
539 \"\\\\\\\\caption[[{]\" will use the caption in a figure or table
540 environment.
541 \"\\\\\\\\begin{eqnarray}\\\\|\\\\\\\\\\\\\\\\\" works for eqnarrays.
542 - If any of `caption', `item', `eqnarray-like', `alignat-like', this
543 symbol will internally be translated into an appropriate regexp
544 (see also the variable `reftex-default-context-regexps').
545 - If a function, call this function with the name of the environment/macro
546 as argument. On call, point will be just after the \\label macro. The
547 function is expected to return a suitable context string. It should
548 throw an exception (error) when failing to find context.
549 As an example, here is a function returning the 10 chars following
550 the label macro as context:
551
552 (defun my-context-function (env-or-mac)
553 (if (> (point-max) (+ 10 (point)))
554 (buffer-substring (point) (+ 10 (point)))
555 (error \"Buffer too small\")))
556
557 Label context is used in two ways by RefTeX: For display in the label
558 menu, and to derive a label string. If you want to use a different
559 method for each of these, specify them as a dotted pair.
560 E.g. `(nil . t)' uses the text after the label (nil) for display, and
561 text from the default position (t) to derive a label string. This is
562 actually used for section labels.
563
564MAGIC-WORDS
565 List of magic words which identify a reference to be of this type.
566 If the word before point is equal to one of these words when calling
567 `reftex-reference', the label list offered will be automatically
568 restricted to labels of the correct type.
569 If the first element of this wordlist is the symbol `regexp', the
570 strings are interpreted as regular expressions. RefTeX will add
571 a \"\\\\W\" to the beginning and other stuff to the end of the regexp.
572
7c4d13cc
CD
573TOC-LEVEL
574 The integer level at which this environment should be added to the
575 table of contents. See also `reftex-section-levels'. A positive
576 value will number the entries mixed with the sectioning commands of
577 the same level. A negative value will make unnumbered entries.
578 Useful only for theorem-like environments, will be ignored for macros.
579 When omitted or nil, no TOC entries will be made.
580
1a9461d0
CD
581If the type indicator characters of two or more entries are the same, RefTeX
582will use
583 - the first non-nil format and prefix
584 - the magic words of all involved entries.
585
586Any list entry may also be a symbol. If that has an association in
587`reftex-label-alist-builtin', the cddr of that association is spliced into the
588list. However, builtin defaults should normally be set with the variable
983741d8 589`reftex-default-label-alist-entries'."
1a9461d0
CD
590 :group 'reftex-defining-label-environments
591 :set 'reftex-set-dirty
592 :type
593 `(repeat
594 (choice :tag "Package or Detailed "
595 :value ("" ?a nil nil nil nil)
596 (list :tag "Detailed Entry"
597 :value ("" ?a nil nil nil nil)
598 (choice :tag "Environment or \\macro "
599 (const :tag "Ignore, just use typekey" nil)
600 (string "")
3666daf6
CD
601 (symbol :tag "Special parser" my-parser))
602 (choice :tag "Type specification "
603 (const :tag "unspecified, like in \\label" nil)
604 (character :tag "Char " ?a))
1a9461d0
CD
605 (choice :tag "Label prefix string "
606 (const :tag "Default" nil)
607 (string :tag "String" "lab:"))
608 (choice :tag "Label reference format"
609 (const :tag "Default" nil)
610 (string :tag "String" "~\\ref{%s}"))
611 (choice :tag "Context method "
3666daf6
CD
612 (const :tag "Default position" t)
613 (const :tag "After label" nil)
614 (number :tag "Macro arg nr" 1)
615 (regexp :tag "Regexp" "")
616 (const :tag "Caption in float" caption)
617 (const :tag "Item in list" item)
618 (const :tag "Eqnarray-like" eqnarray-like)
619 (const :tag "Alignat-like" alignat-like)
620 (symbol :tag "Function" my-func))
621 (repeat :tag "Magic words" :extra-offset 2 (string))
622 (option (choice :tag "Make TOC entry "
623 (const :tag "No entry" nil)
624 (integer :tag "Level" :value -3))))
1a9461d0
CD
625 (choice
626 :tag "Package"
627 :value AMSTeX
628 ,@(mapcar
3666daf6
CD
629 (lambda (x)
630 (list 'const :tag (concat (symbol-name (nth 0 x)))
631 (nth 0 x)))
632 reftex-label-alist-builtin)))))
1a9461d0 633
1a9461d0
CD
634(defcustom reftex-section-prefixes '((0 . "part:") (1 . "cha:") (t . "sec:"))
635 "Prefixes for section labels.
636When the label prefix given in an entry in `reftex-label-alist' contains `%S',
c8de140b 637this list is used to determine the correct prefix string depending on the
1a9461d0
CD
638current section level.
639The list is an alist, with each entry of the form (KEY . PREFIX)
640Possible keys are sectioning macro names like `chapter', section levels
3666daf6 641\(as given in `reftex-section-levels'), and t for the default."
1a9461d0
CD
642 :group 'reftex-defining-label-environments
643 :type '(repeat
3666daf6
CD
644 (cons :value (0 . "")
645 (choice
646 (string :tag "macro name")
647 (integer :tag "section level")
648 (const :tag "default" t))
649 (string :tag "Prefix"))))
1a9461d0
CD
650
651(defcustom reftex-default-context-regexps
652 '((caption . "\\\\\\(rot\\)?caption\\*?[[{]")
653 (item . "\\\\item\\(\\[[^]]*\\]\\)?")
654 (eqnarray-like . "\\\\begin{%s}\\|\\\\\\\\")
655 (alignat-like . "\\\\begin{%s}{[0-9]*}\\|\\\\\\\\"))
656"Alist with default regular expressions for finding context.
657The form (format regexp (regexp-quote environment)) is used to calculate
658the final regular expression - so %s will be replaced with the environment
659or macro."
660 :group 'reftex-defining-label-environments
661 :type '(repeat (cons (symbol) (regexp))))
f3c18bd0
CD
662
663(defcustom reftex-trust-label-prefix nil
664 "Non-nil means, trust the label prefix when determining label type.
665It is customary to use special label prefixes to distinguish different label
666types. The label prefixes have no syntactic meaning in LaTeX (unless
3a1e8128 667special packages like fancyref are being used). RefTeX can and by
f3c18bd0
CD
668default does parse around each label to detect the correct label type,
669but this process can be slow when a document contains thousands of
670labels. If you use label prefixes consistently, you may speed up
671document parsing by setting this variable to a non-nil value. RefTeX
672will then compare the label prefix with the prefixes found in
673`reftex-label-alist' and derive the correct label type in this way.
674Possible values for this option are:
675
676t This means to trust any label prefixes found.
677regexp If a regexp, only prefixes matched by the regexp are trusted.
678list List of accepted prefixes, as strings. The colon is part of
679 the prefix, e.g. (\"fn:\" \"eqn:\" \"item:\").
680nil Never trust a label prefix.
681
682The only disadvantage of using this feature is that the label context
683displayed in the label selection buffer along with each label is
684simply some text after the label definition. This is no problem if you
685place labels keeping this in mind (e.g. *before* the equation, *at
686the beginning* of a fig/tab caption ...). Anyway, it is probably best
687to use the regexp or the list value types to fine-tune this feature.
688For example, if your document contains thousands of footnotes with
689labels fn:xxx, you may want to set this variable to the value \"^fn:$\" or
690\(\"fn:\"). Then RefTeX will still do extensive parsing for any
691non-footnote labels."
692 :group 'reftex-defining-label-environments
693 :type '(choice
694 (const :tag "Always" t)
695 (const :tag "Never" nil)
696 (regexp)
697 (repeat :tag "List"
698 (string :tag "prefix (with colon)"))))
c8de140b 699
1a9461d0
CD
700(defcustom reftex-special-environment-functions nil
701 "List of functions to be called when trying to figure out current environment.
702These are special functions to detect \"environments\" which do not
703start with \\begin and end with \\end. Some LaTeX packages seem to
704use such non-standard ways to set up environment-like constructs. The
705purpose of each function in this list is to detect if point is
706currently inside such a special \"environment\". If the environment
707carries a label, you must also set up an entry for it in
708`reftex-label-alist'.
709
710The function should check if point is currently in the special
711environment it was written to detect. If so, the function must return
712a cons cell (NAME . POSITION). NAME is the name of the environment
713detected and POSITION is the buffer position where the environment
714starts. The function must return nil on failure to detect the
715environment.
716
717The function must take an argument BOUND. If non-nil, BOUND is a
718boundary for backwards searches which should be observed.
719
720Here is an example. The LaTeX package linguex.sty defines list macros
721`\\ex.', `\\a.', etc for lists which are terminated by `\\z.' or an empty
722line.
723
724 \\ex. \\label{ex:12} Some text in an exotic language ...
725 \\a. \\label{ex:13} more stuff
726 \\b. \\label{ex:14} still more stuff
727
728 ... more text after the empty line terminating all lists
729
730And here is the setup for RefTeX:
731
7321. Define a dummy environment for this in `reftex-label-alist'. Dummy means,
733 make up an environment name even though it is not used with \\begin and
734 \\end. Here we use \"linguex\" as this name.
735
736 (setq reftex-label-alist
737 '((\"linguex\" ?x \"ex:\" \"~\\\\ref{%s}\" nil (\"Example\" \"Ex.\"))))
738
7392. Write a function to detect the list macros and the determinators as well.
740
741 (defun my-detect-linguex-list (bound)
742 (let ((pos (point)) p1)
743 (save-excursion
744 ;; Search for any of the linguex item macros at the beginning of a line
c8de140b 745 (if (re-search-backward
1a9461d0
CD
746 \"^[ \\t]*\\\\(\\\\\\\\\\\\(ex\\\\|a\\\\|b\\\\|c\\\\|d\\\\|e\\\\|f\\\\)g?\\\\.\\\\)\" bound t)
747 (progn
748 (setq p1 (match-beginning 1))
749 ;; Make sure no empty line or \\z. is between us and the item macro
750 (if (re-search-forward \"\\n[ \\t]*\\n\\\\|\\\\\\\\z\\\\.\" pos t)
751 ;; Return nil because list was already closed
752 nil
753 ;; OK, we got it
754 (cons \"linguex\" p1)))
c8de140b 755 ;; Return nil for not found
1a9461d0
CD
756 nil))))
757
7583. Tell RefTeX to use this function
759
4f595e15 760 (setq reftex-special-environment-functions '(my-detect-linguex-list))"
1a9461d0
CD
761 :group 'reftex-defining-label-environments
762 :type 'hook)
763
764;; Label insertion
765
766(defgroup reftex-making-and-inserting-labels nil
767 "Options on how to create new labels."
768 :group 'reftex-label-support)
769
770(defcustom reftex-insert-label-flags '("s" "sft")
771 "Flags governing label insertion. First flag DERIVE, second flag PROMPT.
772
773If DERIVE is t, RefTeX will try to derive a sensible label from context.
774A section label for example will be derived from the section heading.
f8b00e0f 775The conversion of the context to a valid label is governed by the
1a9461d0
CD
776specifications given in `reftex-derive-label-parameters'.
777If RefTeX fails to derive a label, it will prompt the user.
778If DERIVE is nil, the label generated will consist of the prefix and a
779unique number, like `eq:23'.
780
781If PROMPT is t, the user will be prompted for a label string. The prompt will
782already contain the prefix, and (if DERIVE is t) a default label derived from
783context. When PROMPT is nil, the default label will be inserted without
784query.
785
786So the combination of DERIVE and PROMPT controls label insertion. Here is a
787table describing all four possibilities:
788
789DERIVE PROMPT ACTION
790-------------------------------------------------------------------------
791 nil nil Insert simple label, like eq:22 or sec:13. No query.
792 nil t Prompt for label.
793 t nil Derive a label from context and insert without query.
794 t t Derive a label from context and prompt for confirmation.
795
796Each flag may be set to t, nil, or a string of label type letters
797indicating the label types for which it should be true. The strings work
798like character classes.
799Thus, the combination may be set differently for each label type. The
800default settings \"s\" and \"sft\" mean: Derive section labels from headings
3666daf6 801\(with confirmation). Prompt for figure and table labels. Use simple labels
1a9461d0
CD
802without confirmation for everything else.
803The available label types are: s (section), f (figure), t (table), i (item),
804e (equation), n (footnote), N (endnote), plus any definitions in
805`reftex-label-alist'."
806 :group 'reftex-making-and-inserting-labels
807 :type '(list (choice :tag "Derive label from context"
808 (const :tag "always" t)
809 (const :tag "never" nil)
810 (string :tag "selected label types" ""))
811 (choice :tag "Prompt for label string "
812 :entry-format " %b %v"
813 (const :tag "always" t)
814 (const :tag "never" nil)
815 (string :tag "selected label types" ""))))
816
817(defcustom reftex-string-to-label-function 'reftex-string-to-label
f8b00e0f 818 "Function to turn an arbitrary string into a valid label.
1a9461d0
CD
819RefTeX's default function uses the variable `reftex-derive-label-parameters'."
820 :group 'reftex-making-and-inserting-labels
821 :type 'symbol)
822
823(defcustom reftex-translate-to-ascii-function 'reftex-latin1-to-ascii
4f595e15
RA
824 "Filter function to convert a string to ASCII.
825The function is used to process a context string before it is
826used to derive a label from it. The intended application is to
827convert ISO or Mule characters into something valid in labels.
828The default function removes the accents from Latin-1 characters.
829X-Symbol (>=2.6) sets this variable to the much more general
830`x-symbol-translate-to-ascii'."
1a9461d0
CD
831 :group 'reftex-making-and-inserting-labels
832 :type 'symbol)
833
834(defcustom reftex-derive-label-parameters '(3 20 t 1 "-"
835 ("the" "on" "in" "off" "a" "for" "by" "of" "and" "is" "to") t)
836 "Parameters for converting a string into a label.
837This variable is a list of the following items.
838
839NWORDS Number of words to use.
840MAXCHAR Maximum number of characters in a label string.
5181ff9f
WL
841INVALID nil: Throw away any words containing characters invalid in labels.
842 t: Throw away only the invalid characters, not the whole word.
1a9461d0
CD
843ABBREV nil: Never abbreviate words.
844 t: Always abbreviate words (see `reftex-abbrev-parameters').
845 not t and not nil: Abbreviate words if necessary to shorten
846 label string below MAXCHAR.
847SEPARATOR String separating different words in the label.
848IGNOREWORDS List of words which should not be part of labels.
849DOWNCASE t: Downcase words before using them."
850 :group 'reftex-making-and-inserting-labels
851 :type '(list (integer :tag "Number of words " 3)
852 (integer :tag "Maximum label length " 20)
5181ff9f 853 (choice :tag "Invalid characters in words"
1a9461d0
CD
854 (const :tag "throw away entire word" nil)
855 (const :tag "throw away single chars" t))
856 (choice :tag "Abbreviate words "
857 (const :tag "never" nil)
858 (const :tag "always" t)
859 (const :tag "when label is too long" 1))
860 (string :tag "Separator between words " "-")
861 (repeat :tag "Ignore words"
862 :entry-format " %i %d %v"
863 (string :tag ""))
3666daf6 864 (option (boolean :tag "Downcase words "))))
1a9461d0
CD
865
866(defcustom reftex-label-illegal-re "[^-a-zA-Z0-9_+=:;,.]"
5181ff9f 867 "Regexp matching characters not valid in labels."
1a9461d0
CD
868 :group 'reftex-making-and-inserting-labels
869 :type '(regexp :tag "Regular Expression"))
870
871(defcustom reftex-abbrev-parameters '(4 2 "^aeiou" "aeiou")
872 "Parameters for abbreviation of words.
873This variable is a list of the following items.
874
875MIN-CHARS Minimum number of characters remaining after abbreviation.
876MIN-KILL Minimum number of characters to remove when abbreviating words.
877BEFORE Character class before abbrev point in word.
878AFTER Character class after abbrev point in word."
879 :group 'reftex-making-and-inserting-labels
880 :type '(list
881 (integer :tag "Minimum chars per word" 4)
882 (integer :tag "Shorten by at least " 2)
883 (string :tag "cut before char class " "^saeiou")
884 (string :tag "cut after char class " "aeiou")))
885
886(defcustom reftex-format-label-function nil
887 "Function which produces the string to insert as a label definition.
888Normally should be nil, unless you want to do something fancy.
889The function will be called with two arguments, the LABEL and the DEFAULT
70d797cd 890FORMAT, which usually is `\\label{%s}'. The function should return the
1a9461d0
CD
891string to insert into the buffer."
892 :group 'reftex-making-and-inserting-labels
893 :type 'function)
894
895;; Label referencing
896
897(defgroup reftex-referencing-labels nil
898 "Options on how to reference labels."
899 :group 'reftex-label-support)
900
901(eval-and-compile
902 (defconst reftex-tmp
903 '((const :tag "on" t)
904 (const :tag "off" nil)
905 (string :tag "Selected label types"))))
906
907(defcustom reftex-label-menu-flags '(t t nil nil nil nil t nil)
908 "List of flags governing the label menu makeup.
909The flags are:
910
911TABLE-OF-CONTENTS Show the labels embedded in a table of context.
912SECTION-NUMBERS Include section numbers (like 4.1.3) in table of contents.
913COUNTERS Show counters. This just numbers the labels in the menu.
914NO-CONTEXT Non-nil means do NOT show the short context.
915FOLLOW Follow full context in other window.
916SHOW-COMMENTED Show labels from regions which are commented out.
917MATCH-IN-TOC Obsolete flag.
918SHOW FILES Show begin and end of included files.
919
920Each of these flags can be set to t or nil, or to a string of type letters
921indicating the label types for which it should be true. These strings work
922like character classes in regular expressions. Thus, setting one of the
923flags to \"sf\" makes the flag true for section and figure labels, nil
924for everything else. Setting it to \"^sf\" makes it the other way round.
925The available label types are: s (section), f (figure), t (table), i (item),
926e (equation), n (footnote), plus any definitions in `reftex-label-alist'.
927
928Most options can also be switched from the label menu itself - so if you
929decide here to not have a table of contents in the label menu, you can still
930get one interactively during selection from the label menu."
931 :group 'reftex-referencing-labels
932 :type
933 `(list
934 (choice :tag "Embed in table of contents " ,@reftex-tmp)
935 (choice :tag "Show section numbers " ,@reftex-tmp)
936 (choice :tag "Show individual counters " ,@reftex-tmp)
937 (choice :tag "Hide short context " ,@reftex-tmp)
938 (choice :tag "Follow context in other window " ,@reftex-tmp)
939 (choice :tag "Show commented labels " ,@reftex-tmp)
3666daf6 940 (choice :tag "Obsolete flag, Don't use. " ,@reftex-tmp)
1a9461d0
CD
941 (choice :tag "Show begin/end of included files" ,@reftex-tmp)))
942
943(defcustom reftex-multiref-punctuation '((?, . ", ") (?- . "--") (?+ . " and "))
944 "Punctuation strings for multiple references.
945When marking is used in the selection buffer to select several references,
946this variable associates the 3 marking characters `,-+' with prefix strings
70d797cd 947to be inserted into the buffer before the corresponding \\ref macro.
1a9461d0
CD
948This is used to string together whole reference sets, like
949`eqs. 1,2,3-5,6 and 7' in a single call to `reftex-reference'. See manual."
950 :group 'reftex-referencing-labels
951 :type '(repeat (cons (character) (string))))
952
4f595e15
RA
953(defcustom reftex-ref-style-alist
954 '(("Default" t
955 (("\\ref" ?\C-m) ("\\pageref" ?p)))
956 ("Varioref" "varioref"
957 (("\\vref" ?v) ("\\vpageref" ?g) ("\\Vref" ?V) ("\\Ref" ?R)))
958 ("Fancyref" "fancyref"
959 (("\\fref" ?f) ("\\Fref" ?F)))
960 ("Hyperref" "hyperref"
961 (("\\autoref" ?a) ("\\autopageref" ?u))))
962 "Alist of reference styles.
963Each element is a list of the style name, the name of the LaTeX
964package associated with the style or t for any package, and an
965alist of macros where the first entry of each item is the
966reference macro and the second a key for selecting the macro when
967the macro type is being prompted for. (See also
968`reftex-ref-macro-prompt'.) The keys, represented as characters,
969have to be unique."
970 :group 'reftex-referencing-labels
971 :type '(alist :key-type (string :tag "Style name")
972 :value-type (group (choice :tag "Package"
973 (const :tag "Any package" t)
974 (string :tag "Name"))
975 (repeat :tag "Macros"
976 (group (string :tag "Macro")
977 (character :tag "Key"))))))
978
979(defcustom reftex-ref-macro-prompt t
980 "If non-nil, `reftex-reference' prompts for the reference macro."
981 :group 'reftex-referencing-labels
982 :type 'boolean)
983
1a9461d0 984(defcustom reftex-vref-is-default nil
4f595e15
RA
985 "Non-nil means, the varioref reference style is used as default.
986The value of this variable determines the default which is active
987when entering the selection process. Instead of nil or t, this
988may also be a string of type letters indicating the label types
989for which it should be true.
990
991This variable is obsolete, use `reftex-ref-style-default-list'
992instead."
1a9461d0
CD
993 :group 'reftex-referencing-labels
994 :type `(choice :tag "\\vref is default macro" ,@reftex-tmp))
0a206828 995;;;###autoload(put 'reftex-vref-is-default 'safe-local-variable (lambda (x) (or (stringp x) (symbolp x))))
1a9461d0
CD
996
997(defcustom reftex-fref-is-default nil
4f595e15
RA
998 "Non-nil means, the fancyref reference style is used as default.
999The value of this variable determines the default which is active
1000when entering the selection process. Instead of nil or t, this
1001may also be a string of type letters indicating the label types
1002for which it should be true.
1003
1004This variable is obsolete, use `reftex-ref-style-default-list'
1005instead."
1a9461d0
CD
1006 :group 'reftex-referencing-labels
1007 :type `(choice :tag "\\fref is default macro" ,@reftex-tmp))
0a206828 1008;;;###autoload(put 'reftex-fref-is-default 'safe-local-variable (lambda (x) (or (stringp x) (symbolp x))))
1a9461d0 1009
4f595e15
RA
1010(defcustom reftex-ref-style-default-list '("Default")
1011 "List of reference styles to be activated by default.
1012The order is significant and controls the order in which macros
1013can be cycled in the buffer for selecting a label. The entries
1014in the list have to match the respective reference style names
1015used in the variable `reftex-ref-style-alist'."
1016 :group 'reftex-referencing-labels
1017 :type `(set ,@(mapcar (lambda (x) (list 'const (car x)))
1018 reftex-ref-style-alist)))
1019
1020;; Compatibility with obsolete variables.
1021(when reftex-vref-is-default
1022 (add-to-list 'reftex-ref-style-default-list "Varioref"))
1023(when reftex-fref-is-default
1024 (add-to-list 'reftex-ref-style-default-list "Fancyref"))
1025
1a9461d0 1026(defcustom reftex-level-indent 2
fb7ada5f 1027 "Number of spaces to be used for indentation per section level."
1a9461d0
CD
1028 :group 'reftex-referencing-labels
1029 :type 'integer)
6c07f4d4 1030;;;###autoload(put 'reftex-level-indent 'safe-local-variable 'integerp)
1a9461d0
CD
1031
1032(defcustom reftex-guess-label-type t
fb7ada5f 1033 "Non-nil means, `reftex-reference' will try to guess the label type.
1a9461d0
CD
1034To do that, RefTeX will look at the word before the cursor and compare it with
1035the words given in `reftex-label-alist'. When it finds a match, RefTeX will
1036immediately offer the correct label menu - otherwise it will prompt you for
1037a label type. If you set this variable to nil, RefTeX will always prompt."
1038 :group 'reftex-referencing-labels
1039 :type 'boolean)
a55b741e 1040;;;###autoload(put 'reftex-guess-label-type 'safe-local-variable (lambda (x) (memq x '(nil t))))
1a9461d0
CD
1041
1042(defcustom reftex-format-ref-function nil
1043 "Function which produces the string to insert as a reference.
4f595e15
RA
1044Normally should be nil, because the format to insert a reference
1045can already be specified in `reftex-label-alist'.
1046
1047This hook also is used by the special commands to insert
1048e.g. `\\vref' and `\\fref' references, so even if you set this,
1049your setting will be ignored by the special commands.
1050
1051The function will be called with three arguments, the LABEL, the
1052DEFAULT FORMAT, which normally is `~\\ref{%s}' and the REFERENCE
1053STYLE. The function should return the string to insert into the
1054buffer."
1a9461d0 1055 :group 'reftex-referencing-labels
4f595e15 1056 :type '(choice (const nil) function))
1a9461d0
CD
1057
1058(defcustom reftex-select-label-mode-hook nil
4f595e15 1059 "Mode hook for `reftex-select-label-mode'."
1a9461d0
CD
1060 :group 'reftex-referencing-labels
1061 :type 'hook)
1062
1063;; BibteX citation configuration ----------------------------------------
1064
1065(defgroup reftex-citation-support nil
1066 "Support for referencing bibliographic data with BibTeX."
1067 :group 'reftex)
1068
4f595e15
RA
1069(defcustom reftex-bibliography-commands
1070 '("bibliography" "nobibliography" "setupbibtex\\[.*?database=")
6fbeb429
CD
1071 "LaTeX commands which specify the BibTeX databases to use with the document."
1072 :group 'reftex-citation-support
1073 :type '(repeat string))
1074
1075
1a9461d0
CD
1076(defvar reftex-bibfile-ignore-list nil) ; compatibility
1077(defcustom reftex-bibfile-ignore-regexps nil
fb7ada5f 1078 "List of regular expressions to exclude files in \\bibliography{..}.
1a9461d0
CD
1079File names matched by these regexps will not be parsed by RefTeX.
1080Intended for files which contain only `@string' macro definitions and the
1081like, which are ignored by RefTeX anyway."
1082 :group 'reftex-citation-support
1083 :set 'reftex-set-dirty
1084 :type '(repeat (regexp)))
1085
1086(defcustom reftex-default-bibliography nil
fb7ada5f 1087 "List of BibTeX database files which should be used if none are specified.
1a9461d0 1088When `reftex-citation' is called from a document which has neither a
70d797cd 1089`\\bibliography{..}' statement nor a `thebibliography' environment,
1a9461d0
CD
1090RefTeX will scan these files instead. Intended for using `reftex-citation'
1091in non-LaTeX files. The files will be searched along the BIBINPUTS or TEXBIB
1092path."
1093 :group 'reftex-citation-support
1094 :type '(repeat (file)))
1095
1096(defcustom reftex-sort-bibtex-matches 'reverse-year
fb7ada5f 1097 "Sorting of the entries found in BibTeX databases by reftex-citation.
1a9461d0
CD
1098Possible values:
1099nil Do not sort entries.
1100'author Sort entries by author name.
1101'year Sort entries by increasing year.
1102'reverse-year Sort entries by decreasing year."
1103 :group 'reftex-citation-support
1104 :type '(choice (const :tag "not" nil)
1105 (const :tag "by author" author)
1106 (const :tag "by year" year)
1107 (const :tag "by year, reversed" reverse-year)))
1108
1109(defcustom reftex-cite-format 'default
fb7ada5f 1110 "The format of citations to be inserted into the buffer.
1a9461d0
CD
1111It can be a string or an alist or a symbol. In the simplest case this
1112is just the string \"\\cite{%l}\", which is also the default. See the
1113definition of `reftex-cite-format-builtin' for more complex examples.
1114
1115If `reftex-cite-format' is a string, it will be used as the format.
1116In the format, the following percent escapes will be expanded.
1117
1118%l The BibTeX label of the citation.
6fbeb429 1119%a List of author names, see also `reftex-cite-punctuation'.
1a9461d0
CD
1120%2a Like %a, but abbreviate more than 2 authors like Jones et al.
1121%A First author name only.
1122%e Works like %a, but on list of editor names. (%2e and %E work a well)
1123
1124It is also possible to access all other BibTeX database fields:
1125%b booktitle %c chapter %d edition %h howpublished
1126%i institution %j journal %k key %m month
1127%n number %o organization %p pages %P first page
1128%r address %s school %u publisher %t title
c8de140b 1129%v volume %y year
1a9461d0
CD
1130%B booktitle, abbreviated %T title, abbreviated
1131
1132Usually, only %l is needed. The other stuff is mainly for the echo area
1133display, and for (setq reftex-comment-citations t).
1134
c8de140b 1135%< as a special operator kills punctuation and space around it after the
1a9461d0
CD
1136string has been formatted.
1137
f3c18bd0
CD
1138A pair of square brackets indicates an optional argument, and RefTeX
1139will prompt for the values of these arguments.
1140
1a9461d0
CD
1141Beware that all this only works with BibTeX database files. When
1142citations are made from the \\bibitems in an explicit thebibliography
1143environment, only %l is available.
1144
1145If `reftex-cite-format' is an alist of characters and strings, the user
1146will be prompted for a character to select one of the possible format
1147strings.
1148 In order to configure this variable, you can either set
1149`reftex-cite-format' directly yourself or set it to the SYMBOL of one of
c8de140b 1150the predefined styles. The predefined symbols are those which have an
1a9461d0
CD
1151association in the constant `reftex-cite-format-builtin'.
1152E.g.: (setq reftex-cite-format 'natbib)"
1153 :group 'reftex-citation-support
1154 :type
1155 `(choice
1156 :format "%{%t%}: \n%[Value Menu%] %v"
1157 (radio :tag "Symbolic Builtins"
1158 :indent 4
1159 :value default
1160 ,@(mapcar
1161 (lambda (x)
1162 (list 'const :tag (concat (symbol-name (nth 0 x))
1163 ": " (nth 1 x))
1164 (nth 0 x)))
1165 reftex-cite-format-builtin))
1166 (string :tag "format string" "\\cite{%l}")
1167 (repeat :tag "key-ed format strings"
1168 :value ((?\r . "\\cite{%l}")
1169 (?t . "\\cite{%l}") (?p . "\\cite{%l}"))
1170 (cons (character :tag "Key character" ?\r)
1171 (string :tag "Format string" "")))))
1172
f3c18bd0 1173(defcustom reftex-cite-prompt-optional-args 'maybe
fb7ada5f 1174 "Non-nil means, prompt for empty optional arguments in cite macros.
4f595e15 1175When an entry in `reftex-cite-format' is given with square brackets to
f3c18bd0
CD
1176indicate optional arguments (for example \\cite[][]{%l}), RefTeX can
1177prompt for values. Possible values are:
1178
1179nil Never prompt for optional arguments
1180t Always prompt
1181maybe Prompt only if `reftex-citation' was called with C-u prefix arg
1182
1183Unnecessary empty optional arguments are removed before insertion into
1184the buffer. See `reftex-cite-cleanup-optional-args'."
1185 :group 'reftex-citation-support
1186 :type '(choice
1187 (const :tag "Always" t)
1188 (const :tag "When called with prefix arg" maybe)
1189 (const :tag "Never" nil)))
1190
1191(defcustom reftex-cite-cleanup-optional-args t
fb7ada5f 1192 "Non-nil means, remove unnecessary empty optional arguments in cite macros.
f3c18bd0
CD
1193The cite macros provided by some packages (for example
1194natbib) allow specifying two optional arguments, one for a prefix to
1195the citation, and a second for a postfix. When only one optional
1196argument is given, it is interpreted as postfix. When this option is
1197t, RefTeX removes unnecessary empty optional arguments from the cite
1198macro before insertion. For example, it will change
1199 \\cite[][]{Jones} -> \\cite{Jones}
1200 \\cite[][Chapter 1]{Jones} -> \\cite[Chapter 1]{Jones}
1201 \\cite[see][]{Jones} -> \\cite[see][]{Jones}
1202 \\cite[see][Chapter 1]{Jones} -> \\cite{Jones}
1203Is is possible that other packages have other conventions about which
1204optional argument is interpreted how - that is why this cleaning up
1205can be turned off."
1206 :group 'reftex-citation-support
1207 :type 'boolean)
1208
1a9461d0 1209(defcustom reftex-comment-citations nil
fb7ada5f 1210 "Non-nil means add a comment for each citation describing the full entry.
1a9461d0
CD
1211The comment is formatted according to `reftex-cite-comment-format'."
1212 :group 'reftex-citation-support
1213 :type 'boolean)
1214
1215(defcustom reftex-cite-comment-format
1216 "%% %2a %y, %j %v, %P, %b, %e, %u, %s %<\n"
1217 "Citation format used for commented citations. Must NOT contain %l.
1218See the variable `reftex-cite-format' for possible percent escapes."
1219 :group 'reftex-citation-support
1220 :type 'string)
1221
1222(defcustom reftex-cite-view-format "%2a %y, %T, %B, %j %v:%P, %s %<"
1223 "Citation format used to display citation info in the message area.
1224Must NOT contain %l. See the variable `reftex-cite-format' for
1225possible percent escapes."
1226 :group 'reftex-citation-support
1227 :group 'reftex-viewing-cross-references
1228 :type 'string)
1229
1230(defcustom reftex-cite-punctuation '(", " " \\& " " {\\it et al.}")
1231 "Punctuation for formatting of name lists in citations.
1232This is a list of 3 strings.
c8de140b
JB
12331. Normal names separator, like \", \" in Jones, Brown and Miller
12342. Final names separator, like \" and \" in Jones, Brown and Miller
1a9461d0
CD
12353. The \"et al\" string, like \" {\\it et al.}\" in Jones {\\it et al.}"
1236 :group 'reftex-citation-support
1237 :type '(list
1238 (string :tag "Separator for names ")
1239 (string :tag "Separator for last name in list")
1240 (string :tag "string used as et al. ")))
1241
1242(defcustom reftex-format-cite-function nil
1243 "Function which produces the string to insert as a citation.
c8de140b 1244Normally should be nil, because the format to insert a reference can
1a9461d0
CD
1245already be specified in `reftex-cite-format'.
1246The function will be called with two arguments, the CITATION KEY and the
1247DEFAULT FORMAT, which is taken from `reftex-cite-format'. The function
1248should return the string to insert into the buffer."
1249 :group 'reftex-citation-support
4f595e15 1250 :type '(choice (const nil) function))
1a9461d0
CD
1251
1252(defcustom reftex-select-bib-mode-hook nil
1253 "Mode hook for reftex-select-bib-mode."
1254 :group 'reftex-citation-support
1255 :type 'hook)
1256
4f595e15
RA
1257(defcustom reftex-cite-key-separator ","
1258 "String to be used for separating several keys in a \\cite macro."
1259 :group 'reftex-citation-support
1260 :type 'string)
1261
1262(defcustom reftex-create-bibtex-header nil
1263 "Header to insert in BibTeX files generated by RefTeX."
1264 :group 'reftex-citation-support
1265 :type 'string)
1266
1267(defcustom reftex-create-bibtex-footer nil
1268 "Footer to insert in BibTeX files generated by RefTeX."
1269 :group 'reftex-citation-support
1270 :type 'string)
1271
1a9461d0
CD
1272;; Index Support Configuration
1273
1274(defgroup reftex-index-support nil
1275 "Support for viewing and editing the index."
1276 :group 'reftex)
1277
1278(defcustom reftex-support-index t
fb7ada5f 1279 "Non-nil means, index entries are parsed as well.
1a9461d0
CD
1280Index support is resource intensive and the internal structure holding the
1281parsed information can become quite big. Therefore it can be turned off.
1282When this is nil and you execute a command which requires index support,
1283you will be asked for confirmation to turn it on and rescan the document."
1284 :group 'reftex-index-support
1285 :type 'boolean)
1286
1287(defcustom reftex-index-special-chars '("!" "|" "@" "\"" "\\")
1288 "Special characters in index entries. The value is a list of five strings.
1289These correspond to the makeindex keywords LEVEL ENCAP ACTUAL QUOTE ESCAPE."
1290 :group 'reftex-index-support
1291 :type '(list
3666daf6
CD
1292 (string :tag "LEVEL separator")
1293 (string :tag "ENCAP char ")
1294 (string :tag "ACTUAL char ")
1295 (string :tag "QUOTE char ")
1296 (string :tag "ESCAPE char ")))
1a9461d0
CD
1297
1298(defcustom reftex-index-macros nil
4f595e15
RA
1299 "Macros which define index entries.
1300
1301The structure is
1a9461d0 1302
3666daf6 1303\(MACRO INDEX-TAG KEY PREFIX EXCLUDE REPEAT)
1a9461d0
CD
1304
1305MACRO is the macro. Arguments should be denoted by empty braces like
1306\\index[]{*}. Use square brackets to denote optional arguments. The star
1307marks where the index key is.
1308
1309INDEX-TAG is a short name of the index. \"idx\" and \"glo\" are
1310reserved for the default index and the glossary. Other indices can be
1311defined as well. If this is an integer, the Nth argument of the macro
1312holds the index tag.
1313
1314KEY is a character which is used to identify the macro for input with
1315\\[reftex-index]. ?i, ?I, and ?g are reserved for default index and glossary.
1316
1317PREFIX can be a prefix which is added to the KEY part of the index entry.
1318If you have a macro \\newcommand{\\molec}[1]{#1\\index{Molecules!#1}}, this
1319prefix should be \"Molecules!\". See the manual for details.
1320
1321EXCLUDE can be a function. If this function exists and returns a non-nil
1322value, the index entry at point is ignored. This was implemented to support
1323the (deprecated) `^' and `_' shortcuts in the LaTeX2e `index' package.
1324
7c4d13cc
CD
1325REPEAT, if non-nil, means the index macro does not typeset the entry in
1326the text, so that the text has to be repeated outside the index macro.
1327Needed for `reftex-index-selection-or-word' and for indexing from the
1328phrase buffer.
1329
1a9461d0
CD
1330The final entry may also be a symbol if this entry has a association
1331in the variable `reftex-index-macros-builtin' to specify the main
f8b00e0f 1332indexing package you are using. Valid values are currently
1a9461d0
CD
1333default The LaTeX default - unnecessary to specify this one
1334multind The multind.sty package
1335index The index.sty package
1336index-shortcut The index.sty packages with the ^ and _ shortcuts.
1337 Should not be used - only for old documents.
1338Note that AUCTeX sets these things internally for RefTeX as well, so
1339with a sufficiently new version of AUCTeX, you should not set the
1340package here."
1341 :group 'reftex-index-support
1342 :set 'reftex-set-dirty
1343 :type `(list
c8de140b 1344 (repeat
3666daf6
CD
1345 :inline t
1346 (list :value ("" "idx" ?a "" nil)
1347 (string :tag "Macro with args")
1348 (choice :tag "Index Tag "
1349 (string)
1350 (integer :tag "Macro arg Nr" :value 1))
1351 (character :tag "Access Key ")
1352 (string :tag "Key Prefix ")
1353 (symbol :tag "Exclusion hook ")
7c4d13cc 1354 (boolean :tag "Repeat Outside ")))
3666daf6
CD
1355 (option
1356 :tag "Package:"
1357 (choice :tag "Package"
1358 :value index
1359 ,@(mapcar
1360 (lambda (x)
1361 (list 'const :tag (concat (symbol-name (nth 0 x))
1362 ": " (nth 1 x))
1363 (nth 0 x)))
1364 reftex-index-macros-builtin)))))
1a9461d0 1365
7c4d13cc 1366(defcustom reftex-index-default-macro '(?i "idx")
1a9461d0 1367 "The default index macro for \\[reftex-index-selection-or-word].
7c4d13cc 1368This is a list with (MACRO-KEY DEFAULT-TAG).
1a9461d0
CD
1369
1370MACRO-KEY: Character identifying an index macro - see `reftex-index-macros'.
c8de140b 1371DEFAULT-TAG: This is the tag to be used if the macro requires a TAG argument.
1a9461d0
CD
1372 When this is nil and a TAG is needed, RefTeX will ask for it.
1373 When this is the empty string and the TAG argument of the index
7c4d13cc 1374 macro is optional, the TAG argument will be omitted."
1a9461d0
CD
1375 :group 'reftex-index-support
1376 :type '(list
3666daf6
CD
1377 (character :tag "Character identifying default macro")
1378 (choice :tag "Default index tag "
1379 (const nil)
1380 (string))))
1a9461d0
CD
1381
1382(defcustom reftex-index-default-tag "idx"
1383 "Default index tag.
1384When working with multiple indexes, RefTeX queries for an index tag when
1385creating index entries or displaying a specific index. This variable controls
1386the default offered for these queries. The default can be selected with RET
f8b00e0f 1387during selection or completion. Valid values of this variable are:
1a9461d0
CD
1388
1389nil Do not provide a default index
1390\"tag\" The default index tag given as a string, e.g. \"idx\".
1391last The last used index tag will be offered as default."
1392 :group 'reftex-index-support
1393 :type '(choice
3666daf6
CD
1394 (const :tag "no default" nil)
1395 (const :tag "last used " 'last)
1396 (string :tag "index tag " "idx")))
1a9461d0
CD
1397
1398(defcustom reftex-index-math-format "$%s$"
1399 "Format of index entries when copied from inside math mode.
1400When `reftex-index-selection-or-word' is executed inside TeX math mode,
1401the index key copied from the buffer is processed with this format string
1402through the `format' function. This can be used to add the math delimiters
3666daf6 1403\(e.g. `$') to the string.
1a9461d0
CD
1404Requires the `texmathp.el' library which is part of AUCTeX."
1405 :group 'reftex-index-support
1406 :type 'string)
1407
9f286482
CD
1408(defcustom reftex-index-phrase-file-extension ".rip"
1409 "File extension for the index phrase file.
1410This extension will be added to the base name of the master file."
1411 :group 'reftex-index-support
1412 :type 'string)
1413
7c4d13cc
CD
1414(defcustom reftex-index-phrases-logical-and-regexp " *&& *"
1415 "Regexp matching the `and' operator for index arguments in phrases file.
1416When several index arguments in a phrase line are separated by this
1417operator, each part will generate an index macro. So each match of
1418the search phrase will produce *several* different index entries.
1419
1420Note: make sure this does no match things which are not separators.
1421This logical `and' has higher priority than the logical `or' specified in
1422`reftex-index-phrases-logical-or-regexp'."
1423 :group 'reftex-index-support
1424 :type 'regexp)
1425
1426(defcustom reftex-index-phrases-logical-or-regexp " *|| *"
1427 "Regexp matching the `or' operator for index arguments in phrases file.
1428When several index arguments in a phrase line are separated by this
1429operator, the user will be asked to select one of them at each match
1430of the search phrase. The first index arg will be the default - a
1431number key 1-9 must be pressed to switch to another.
1432
1433Note: make sure this does no match things which are not separators.
1434The logical `and' specified in `reftex-index-phrases-logical-or-regexp'
1435has higher priority than this logical `or'."
1436 :group 'reftex-index-support
1437 :type 'regexp)
1438
1439(defcustom reftex-index-phrases-search-whole-words t
fb7ada5f 1440 "Non-nil means phrases search will look for whole words, not subwords.
7c4d13cc
CD
1441This works by requiring word boundaries at the beginning and end of
1442the search string. When the search phrase already has a non-word-char
1443at one of these points, no word boundary is required there."
1444 :group 'reftex-index-support
1445 :type 'boolean)
1446
1447(defcustom reftex-index-phrases-case-fold-search t
fb7ada5f 1448 "Non-nil means, searching for index phrases will ignore case."
7c4d13cc
CD
1449 :group 'reftex-index-support
1450 :type 'boolean)
1451
6fbeb429
CD
1452(defcustom reftex-index-verify-function nil
1453 "A function which is called at each match during global indexing.
1454If the function returns nil, the current match is skipped."
1455 :group 'reftex-index-support
1456 :type '(choice
3666daf6
CD
1457 (const :tag "No verification" nil)
1458 (function)))
6fbeb429 1459
7c4d13cc 1460(defcustom reftex-index-phrases-skip-indexed-matches nil
fb7ada5f 1461 "Non-nil means, skip matches which appear to be indexed already.
7c4d13cc
CD
1462When doing global indexing from the phrases buffer, searches for some
1463phrases may match at places where that phrase was already indexed. In
1464particular when indexing an already processed document again, this
1465will even be the norm. When this variable is non-nil, RefTeX checks if
3666daf6 1466the match is inside an index macro argument, or if an index macro is directly
7c4d13cc
CD
1467before or after the phrase. If that is the case, that match will
1468be ignored."
1469 :group 'reftex-index-support
1470 :type 'boolean)
1471
1472(defcustom reftex-index-phrases-wrap-long-lines nil
fb7ada5f 1473 "Non-nil means, when indexing from the phrases buffer, wrap lines.
7c4d13cc
CD
1474Inserting indexing commands in a line makes the line longer - often
1475so long that it does not fit onto the screen. When this variable is
1476non-nil, newlines will be added as necessary before and/or after the
1477indexing command to keep lines short. However, the matched text
f5307782
JB
1478phrase and its index command will always end up on a single line."
1479 :group 'reftex-index-support
1480 :type 'boolean)
7c4d13cc
CD
1481
1482(defcustom reftex-index-phrases-sort-prefers-entry nil
fb7ada5f 1483 "Non-nil means when sorting phrase lines, the explicit index entry is used.
7c4d13cc
CD
1484Phrase lines in the phrases buffer contain a search phrase, and
1485sorting is normally based on these. Some phrase lines also have
1486an explicit index argument specified. When this variable is non-nil,
1487the index argument will be used for sorting."
1488 :group 'reftex-index-support
1489 :type 'boolean)
1490
1491(defcustom reftex-index-phrases-sort-in-blocks t
fb7ada5f 1492 "Non-nil means, empty and comment lines separate phrase buffer into blocks.
7c4d13cc
CD
1493Sorting will then preserve blocks, so that lines are re-arranged only
1494within blocks."
1495 :group 'reftex-index-support
1496 :type 'boolean)
1497
1a9461d0
CD
1498(defcustom reftex-index-section-letters "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
1499 "The letters which denote sections in the index.
1500Usually these are all capital letters. Don't use any downcase letters.
1501Order is not significant, the index will be sorted by whatever the sort
1502function thinks is correct.
1503In addition to these letters, RefTeX will create a group `!' which
1504contains all entries sorted below the lowest specified letter.
1505In the index buffer, pressing any of these capital letters or `!' will jump
1506to that section."
1507 :group 'reftex-index-support
1508 :type '(string :tag "Capital letters"))
1509
1510(defcustom reftex-index-include-context nil
fb7ada5f 1511 "Non-nil means, display the index definition context in the index buffer.
c8de140b 1512This flag may also be toggled from the index buffer with the `c' key."
1a9461d0
CD
1513 :group 'reftex-index-support
1514 :type 'boolean)
1515
1516(defcustom reftex-index-follow-mode nil
fb7ada5f 1517 "Non-nil means, point in *Index* buffer will cause other window to follow.
1a9461d0
CD
1518The other window will show the corresponding part of the document.
1519This flag can be toggled from within the *Index* buffer with the `f' key."
1520 :group 'reftex-table-of-contents-browser
1521 :type 'boolean)
1522
1523;; Viewing Cross References
1524
1525(defgroup reftex-viewing-cross-references nil
1526 "Displaying cross references and citations."
1527 :group 'reftex)
1528
1529(defcustom reftex-view-crossref-extra nil
1530 "Macros which can be used for the display of cross references.
1531This is used when `reftex-view-crossref' is called with point in an
1532argument of a macro. Note that crossref viewing for citations,
1533references (both ways) and index entries is hard-coded. This variable
4f595e15 1534is only to configure additional structures for which cross-reference
c8de140b 1535viewing can be useful. Each entry has the structure
1a9461d0 1536
3666daf6 1537\(MACRO-RE SEARCH-RE HIGHLIGHT).
1a9461d0
CD
1538
1539MACRO-RE is matched against the macro. SEARCH-RE is the regexp used
1540to search for cross references. `%s' in this regexp is replaced with
1541with the macro argument at point. HIGHLIGHT is an integer indicating
1542which subgroup of the match should be highlighted."
1543 :group 'reftex-viewing-cross-references
1544 :type '(repeat (group (regexp :tag "Macro Regexp ")
3666daf6
CD
1545 (string :tag "Search Regexp ")
1546 (integer :tag "Highlight Group"))))
1a9461d0
CD
1547
1548(defcustom reftex-auto-view-crossref t
fb7ada5f 1549 "Non-nil means, initially turn automatic viewing of crossref info on.
1a9461d0 1550Automatic viewing of crossref info normally uses the echo area.
3b919c9f
CD
1551Whenever point is idle for more than `reftex-idle-time' seconds on the
1552argument of a \\ref or \\cite macro, and no other message is being
1553displayed, the echo area will display information about that cross
1554reference. You can also set the variable to the symbol `window'. In
1555this case a small temporary window is used for the display.
c8de140b 1556This feature can be turned on and off from the menu
3666daf6 1557\(Ref->Options)."
1a9461d0
CD
1558 :group 'reftex-viewing-cross-references
1559 :type '(choice (const :tag "off" nil)
3666daf6
CD
1560 (const :tag "in Echo Area" t)
1561 (const :tag "in Other Window" window)))
1a9461d0
CD
1562
1563(defcustom reftex-idle-time 1.2
fb7ada5f 1564 "Time (secs) Emacs has to be idle before automatic crossref display is done.
3b919c9f 1565Applies also to toc recentering."
1a9461d0
CD
1566 :group 'reftex-viewing-cross-references
1567 :type 'number)
1568
1569(defcustom reftex-revisit-to-echo nil
fb7ada5f 1570 "Non-nil means, automatic citation display will revisit files if necessary.
1a9461d0
CD
1571When nil, citation display in echo area will only be active for cached
1572entries and for BibTeX database files with live associated buffers."
1573 :group 'reftex-viewing-cross-references
1574 :type 'boolean)
1575
1576(defcustom reftex-cache-cite-echo t
4f595e15
RA
1577 "Non-nil means, echoed information for cite macros is cached.
1578The information displayed in the echo area for cite macros is
1579cached and even saved along with the parsing information. The
1580cache survives document scans. In order to clear it, use M-x
1581reftex-reset-mode <RET>."
1a9461d0
CD
1582 :group 'reftex-viewing-cross-references
1583 :type 'boolean)
1584
1585(defcustom reftex-display-copied-context-hook nil
4f595e15
RA
1586 "Normal hook which is run before context is displayed anywhere.
1587Designed for X-Symbol, but may have other uses as well."
1a9461d0
CD
1588 :group 'reftex-viewing-cross-references
1589 :group 'reftex-referencing-labels
1590 :type 'hook)
1591
1592;; Finding Files --------------------------------------------------------
1593
1594(defgroup reftex-finding-files nil
1595 "Finding files on search paths."
1596 :group 'reftex)
1597
1598(defcustom reftex-texpath-environment-variables '("TEXINPUTS")
fb7ada5f 1599 "List of specifications how to retrieve the search path for TeX files.
1a9461d0
CD
1600Several entries are possible.
1601- If an element is the name of an environment variable, its content is used.
1602- If an element starts with an exclamation mark, it is used as a command
1603 to retrieve the path. A typical command with the kpathsearch library would
c8de140b 1604 be `!kpsewhich -show-path=.tex'.
1a9461d0
CD
1605- Otherwise the element itself is interpreted as a path.
1606Multiple directories can be separated by the system dependent `path-separator'.
1607Directories ending in `//' or `!!' will be expanded recursively.
1608See also `reftex-use-external-file-finders'."
1609 :group 'reftex-finding-files
1610 :set 'reftex-set-dirty
1611 :type '(repeat (string :tag "Specification")))
1612
1613(defcustom reftex-bibpath-environment-variables '("BIBINPUTS" "TEXBIB")
fb7ada5f 1614 "List of specifications how to retrieve search path for .bib database files.
1a9461d0
CD
1615Several entries are possible.
1616- If an element is the name of an environment variable, its content is used.
1617- If an element starts with an exclamation mark, it is used as a command
1618 to retrieve the path. A typical command with the kpathsearch library would
c8de140b 1619 be `!kpsewhich -show-path=.bib'.
1a9461d0
CD
1620- Otherwise the element itself is interpreted as a path.
1621Multiple directories can be separated by the system dependent `path-separator'.
1622Directories ending in `//' or `!!' will be expanded recursively.
1623See also `reftex-use-external-file-finders'."
1624 :group 'reftex-citation-support
1625 :group 'reftex-finding-files
1626 :set 'reftex-set-dirty
1627 :type '(repeat (string :tag "Specification")))
1628
1629(defcustom reftex-file-extensions '(("tex" . (".tex" ".ltx"))
3666daf6 1630 ("bib" . (".bib")))
fb7ada5f 1631 "Association list with file extensions for different file types.
1a9461d0
CD
1632This is a list of items, each item is like: (TYPE . (DEF-EXT OTHER-EXT ...))
1633
1634TYPE: File type like \"bib\" or \"tex\".
1635DEF-EXT: The default extension for that file type, like \".tex\" or \".bib\".
f8b00e0f 1636OTHER-EXT: Any number of other valid extensions for this file type.
1a9461d0 1637
3a1e8128 1638When a files is searched and it does not have any of the legal extensions,
70d797cd
CD
1639we try the default extension first, and then the naked file name.
1640
1641If you are using AUCTeX, you also need to add new extensions to
1642TeX-file-extensions."
1a9461d0
CD
1643 :group 'reftex-finding-files
1644 :type '(repeat (cons (string :tag "File type")
3666daf6 1645 (repeat (string :tag "Extension")))))
1a9461d0 1646
ea2a0e35
CD
1647(defcustom reftex-try-all-extensions nil
1648 "Non-nil means, try all extensions listed in `reftex-file-extensions'.
1649When searching for a file, LaTeX uses only the default extension. However,
1650if you are working with a noweb system that produces the .tex files from
1651some other file, and you want RefTeX to scan the web file instead of the
1652tex file, you need to set this option. You also need to make the noweb
1653extension the default extension, i.e. the first in the list in
1654`reftex-file-extensions'.
1655Note that if you are using external file finders, this option has no effect."
1656 :group 'reftex-finding-files
1657 :type 'boolean)
1658
1a9461d0 1659(defcustom reftex-search-unrecursed-path-first t
fb7ada5f 1660 "Non-nil means, search all specified directories before trying recursion.
1a9461d0
CD
1661Thus, in a path \".//:/tex/\", search first \"./\", then \"/tex/\" and then
1662all subdirectories of \"./\". If this option is nil, the subdirectories of
c8de140b 1663\"./\" are searched before \"/tex/\". This is mainly for speed - most of the
1a9461d0
CD
1664time the recursive path is for the system files and not for the user files.
1665Set this to nil if the default makes RefTeX finding files with equal names
1666in wrong sequence."
1667 :group 'reftex-finding-files
1668 :type 'boolean)
1669
1670(defcustom reftex-use-external-file-finders nil
fb7ada5f 1671 "Non-nil means, use external programs to find files.
1a9461d0
CD
1672Normally, RefTeX searches the paths given in the environment variables
1673TEXINPUTS and BIBINPUTS to find TeX files and BibTeX database files.
1674With this option turned on, it calls an external program specified in the
1675option `reftex-external-file-finders' instead. As a side effect,
c8de140b 1676the variables `reftex-texpath-environment-variables' and
1a9461d0
CD
1677`reftex-bibpath-environment-variables' will be ignored."
1678 :group 'reftex-finding-files
1679 :type 'boolean)
1680
1681(defcustom reftex-external-file-finders '(("tex" . "kpsewhich -format=.tex %f")
3666daf6 1682 ("bib" . "kpsewhich -format=.bib %f"))
fb7ada5f 1683 "Association list with external programs to call for finding files.
1a9461d0
CD
1684Each entry is a cons cell (TYPE . PROGRAM).
1685TYPE is either \"tex\" or \"bib\". PROGRAM is the external program to use with
1686any arguments. %f will be replaced by the name of the file to be found.
1687Note that these commands will be executed directly, not via a shell.
1688Only relevant when `reftex-use-external-file-finders' is non-nil."
1689 :group 'reftex-finding-files
1690 :type '(repeat (cons (string :tag "File type")
3666daf6 1691 (string :tag "Program "))))
1a9461d0
CD
1692
1693;; Tuning the parser ----------------------------------------------------
1694
1695(defgroup reftex-optimizations-for-large-documents nil
1696 "Configuration of parser speed and memory usage."
1697 :group 'reftex)
1698
1699(defcustom reftex-keep-temporary-buffers 1
fb7ada5f 1700 "Non-nil means, keep buffers created for parsing and lookup.
1a9461d0
CD
1701RefTeX sometimes needs to visit files related to the current document.
1702We distinguish files visited for
1703PARSING: Parts of a multifile document loaded when (re)-parsing the document.
1704LOOKUP: BibTeX database files and TeX files loaded to find a reference,
1705 to display label context, etc.
1706The created buffers can be kept for later use, or be thrown away immediately
1707after use, depending on the value of this variable:
1708
1709nil Throw away as much as possible.
1710t Keep everything.
17111 Throw away buffers created for parsing, but keep the ones created
1712 for lookup.
1713
1714If a buffer is to be kept, the file is visited normally (which is potentially
1715slow but will happen only once).
1716If a buffer is to be thrown away, the initialization of the buffer depends
1717upon the variable `reftex-initialize-temporary-buffers'."
1718 :group 'reftex-optimizations-for-large-documents
1719 :type '(choice
1720 (const :tag "Throw away everything" nil)
1721 (const :tag "Keep everything" t)
1722 (const :tag "Keep lookup buffers only" 1)))
1723
1724(defcustom reftex-initialize-temporary-buffers nil
fb7ada5f 1725 "Non-nil means do initializations even when visiting file temporarily.
1a9461d0
CD
1726When nil, RefTeX may turn off find-file hooks and other stuff to briefly
1727visit a file.
1728When t, the full default initializations are done (find-file-hook etc.).
1729Instead of t or nil, this variable may also be a list of hook functions to
1730do a minimal initialization."
1731 :group 'reftex-optimizations-for-large-documents
1732 :type '(choice
1733 (const :tag "Read files literally" nil)
1734 (const :tag "Fully initialize buffers" t)
1735 (repeat :tag "Hook functions" :value (nil)
1736 (function-item))))
1737
1738(defcustom reftex-no-include-regexps '("\\.pstex_t\\'")
fb7ada5f 1739 "List of regular expressions to exclude certain input files from parsing.
1a9461d0
CD
1740If the name of a file included via \\include or \\input is matched by any
1741of the regular expressions in this list, that file is not parsed by RefTeX."
1742 :group 'reftex-optimizations-for-large-documents
1743 :type '(repeat (regexp)))
1744
1745(defcustom reftex-enable-partial-scans nil
fb7ada5f 1746 "Non-nil means, re-parse only 1 file when asked to re-parse.
1a9461d0
CD
1747Re-parsing is normally requested with a `C-u' prefix to many RefTeX commands,
1748or with the `r' key in menus. When this option is t in a multifile document,
1749we will only parse the current buffer, or the file associated with the label
1750or section heading near point in a menu. Requesting re-parsing of an entire
1751multifile document then requires a `C-u C-u' prefix or the capital `R' key
1752in menus."
1753 :group 'reftex-optimizations-for-large-documents
1754 :type 'boolean)
1755
1756(defcustom reftex-allow-automatic-rescan t
fb7ada5f 1757 "Non-nil means, RefTeX may rescan the document when this seems necessary.
1a9461d0
CD
1758Currently this applies only to rescanning after label insertion, when
1759the new label cannot be inserted correctly into the internal label
1760list."
1761 :group 'reftex-optimizations-for-large-documents
1762 :type 'boolean)
1763
1764(defcustom reftex-save-parse-info nil
fb7ada5f 1765 "Non-nil means, save information gathered with parsing in a file.
1a9461d0 1766The file MASTER.rel in the same directory as MASTER.tex is used to save the
c8de140b 1767information. When this variable is t,
1a9461d0
CD
1768- accessing the parsing information for the first time in an editing session
1769 will read that file (if available) instead of parsing the document.
4f595e15 1770- exiting Emacs or killing a buffer in `reftex-mode' will cause a new version
1a9461d0
CD
1771 of the file to be written."
1772 :group 'reftex-optimizations-for-large-documents
1773 :type 'boolean)
1774
9f286482 1775(defcustom reftex-parse-file-extension ".rel"
fb7ada5f 1776 "File extension for the file in which parser information is stored.
9f286482
CD
1777This extension is added to the base name of the master file."
1778 :group 'reftex-optimizations-for-large-documents
1779 :type 'string)
1780
1a9461d0 1781(defcustom reftex-use-multiple-selection-buffers nil
fb7ada5f 1782 "Non-nil means use a separate selection buffer for each label type.
1a9461d0
CD
1783These buffers are kept from one selection to the next and need not to be
1784created for each use - so the menu generally comes up faster. The
1785selection buffers will be erased (and therefore updated) automatically
1786when new labels in its category are added. See the variable
1787`reftex-auto-update-selection-buffers'."
1788 :group 'reftex-optimizations-for-large-documents
1789 :group 'reftex-referencing-labels
1790 :type 'boolean)
1791
1792(defcustom reftex-auto-update-selection-buffers t
fb7ada5f 1793 "Non-nil means, selection buffers will be updated automatically.
1a9461d0
CD
1794When a new label is defined with `reftex-label', all selection buffers
1795associated with that label category are emptied, in order to force an
1796update upon next use. When nil, the buffers are left alone and have to be
1797updated by hand, with the `g' key from the label selection process.
1798The value of this variable will only have any effect when
1799`reftex-use-multiple-selection-buffers' is non-nil."
1800 :group 'reftex-optimizations-for-large-documents
1801 :group 'reftex-referencing-labels
1802 :type 'boolean)
1803
1804;; Fontification and Faces ----------------------------------------------
1805
1806(defgroup reftex-fontification-configurations nil
1807 "Options concerning the faces used in RefTeX."
8ec3bce0 1808 :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces)
1a9461d0
CD
1809 :group 'reftex)
1810
1811(defcustom reftex-use-fonts t
fb7ada5f 1812 "Non-nil means, use fonts in *toc* and selection buffers.
1a9461d0
CD
1813Font-lock must be loaded as well to actually get fontified display.
1814When changing this option, a rescan may be necessary to activate the change."
1815 :group 'reftex-fontification-configurations
1816 :type 'boolean)
1817
1818(defcustom reftex-refontify-context 1
fb7ada5f 1819 "Non-nil means, re-fontify the context in the label menu with font-lock.
1a9461d0
CD
1820This slightly slows down the creation of the label menu. It is only necessary
1821when you definitely want the context fontified.
1822
1823This option may have 3 different values:
1824nil Never refontify.
1825t Always refontify.
18261 Refontify when absolutely necessary, e.g. when old versions of X-Symbol.
1827The option is ignored when `reftex-use-fonts' is nil."
1828 :group 'reftex-fontification-configurations
1829 :group 'reftex-referencing-labels
1830 :type '(choice
1831 (const :tag "Never" nil)
1832 (const :tag "Always" t)
1833 (const :tag "When necessary" 1)))
1834
1835(defcustom reftex-highlight-selection 'cursor
fb7ada5f 1836 "Non-nil mean, highlight selected text in selection and *toc* buffers.
1a9461d0 1837Normally, the text near the cursor is the selected text, and it is
9858f6c3 1838highlighted. This is the entry most keys in the selection and *toc*
1a9461d0
CD
1839buffers act on. However, if you mainly use the mouse to select an
1840item, you may find it nice to have mouse-triggered highlighting
c8de140b 1841instead or as well. The variable may have one of these values:
1a9461d0
CD
1842
1843 nil No highlighting.
1844 cursor Highlighting is cursor driven.
1845 mouse Highlighting is mouse driven.
1846 both Both cursor and mouse trigger highlighting.
1847
1848Changing this variable requires to rebuild the selection and *toc* buffers
1849to become effective (keys `g' or `r')."
1850 :group 'reftex-fontification-configurations
1851 :type '(choice
3666daf6
CD
1852 (const :tag "Never" nil)
1853 (const :tag "Cursor driven" cursor)
1854 (const :tag "Mouse driven" mouse)
1855 (const :tag "Mouse and Cursor driven." both)))
1a9461d0
CD
1856
1857(defcustom reftex-cursor-selected-face 'highlight
1858 "Face name to highlight cursor selected item in toc and selection buffers.
1859See also the variable `reftex-highlight-selection'."
1860 :group 'reftex-fontification-configurations
1861 :type 'symbol)
1862(defcustom reftex-mouse-selected-face 'secondary-selection
1863 "Face name to highlight mouse selected item in toc and selection buffers.
1864See also the variable `reftex-highlight-selection'."
1865 :group 'reftex-fontification-configurations
1866 :type 'symbol)
1867(defcustom reftex-file-boundary-face 'font-lock-comment-face
1868 "Face name for file boundaries in selection buffer."
1869 :group 'reftex-fontification-configurations
1870 :type 'symbol)
1871(defcustom reftex-label-face 'font-lock-constant-face
1872 "Face name for labels in selection buffer."
1873 :group 'reftex-fontification-configurations
1874 :type 'symbol)
1875(defcustom reftex-section-heading-face 'font-lock-function-name-face
1876 "Face name for section headings in toc and selection buffers."
1877 :group 'reftex-fontification-configurations
1878 :type 'symbol)
1879(defcustom reftex-toc-header-face 'font-lock-comment-face
1880 "Face name for the header of a toc buffer."
1881 :group 'reftex-fontification-configurations
1882 :type 'symbol)
1883(defcustom reftex-bib-author-face 'font-lock-keyword-face
1884 "Face name for author names in bib selection buffer."
1885 :group 'reftex-fontification-configurations
1886 :type 'symbol)
1887(defcustom reftex-bib-year-face 'font-lock-comment-face
1888 "Face name for year in bib selection buffer."
1889 :group 'reftex-fontification-configurations
1890 :type 'symbol)
1891(defcustom reftex-bib-title-face 'font-lock-function-name-face
1892 "Face name for article title in bib selection buffer."
1893 :group 'reftex-fontification-configurations
1894 :type 'symbol)
1895(defcustom reftex-bib-extra-face 'font-lock-comment-face
1896 "Face name for bibliographic information in bib selection buffer."
1897 :group 'reftex-fontification-configurations
1898 :type 'symbol)
1899(defcustom reftex-select-mark-face 'bold
1900 "Face name for marked entries in the selection buffers."
1901 :group 'reftex-fontification-configurations
1902 :type 'symbol)
1903(defcustom reftex-index-header-face 'font-lock-comment-face
1904 "Face name for the header of an index buffer."
1905 :group 'reftex-fontification-configurations
1906 :type 'symbol)
1907(defcustom reftex-index-section-face 'font-lock-function-name-face
1908 "Face name for the start of a new letter section in the index."
1909 :group 'reftex-fontification-configurations
1910 :type 'symbol)
1911(defcustom reftex-index-tag-face 'font-lock-keyword-face
1912 "Face name for index names (for multiple indices)."
1913 :group 'reftex-fontification-configurations
1914 :type 'symbol)
1915(defcustom reftex-index-face 'font-lock-constant-face
1916 "Face name for index entries."
1917 :group 'reftex-fontification-configurations
1918 :type 'symbol)
1919
1920(defcustom reftex-pre-refontification-functions nil
1921 "X-Symbol specific hook.
1922Functions get two arguments, the buffer from where the command started and a
1923symbol indicating in what context the hook is called."
1924 :group 'reftex-fontification-configurations
1925 :type 'hook)
1926
1927;; Miscellaneous configurations -----------------------------------------
1928
1929(defgroup reftex-miscellaneous-configurations nil
1930 "Collection of further configurations."
1931 :group 'reftex)
1932
1933(defcustom reftex-extra-bindings nil
1934 "Non-nil means, make additional key bindings on startup.
4f595e15 1935These extra bindings are located in the users `C-c letter' map."
1a9461d0
CD
1936 :group 'reftex-miscellaneous-configurations
1937 :type 'boolean)
1938
1939(defcustom reftex-plug-into-AUCTeX nil
fb7ada5f 1940 "Plug-in flags for AUCTeX interface.
4f595e15 1941This variable is a list of 5 boolean flags. When a flag is non-nil,
1a9461d0
CD
1942RefTeX will
1943
1944 - supply labels in new sections and environments (flag 1)
1945 - supply arguments for macros like `\\label'. (flag 2)
1946 - supply arguments for macros like `\\ref'. (flag 3)
1947 - supply arguments for macros like `\\cite'. (flag 4)
1948 - supply arguments for macros like `\\index'. (flag 5)
1949
1950You may also set the variable itself to t or nil in order to turn all
1951plug-ins on or off, respectively.
1952\\<LaTeX-mode-map>Supplying labels in new sections and environments applies when creating
1953sections with \\[LaTeX-section] and environments with \\[LaTeX-environment].
1954Supplying macro arguments applies when you insert such a macro interactively
1955with \\[TeX-insert-macro].
1956See the AUCTeX documentation for more information.
1957RefTeX uses `fset' to take over the function calls. Changing the variable
1958may require a restart of Emacs in order to become effective."
1959 :group 'reftex-miscellaneous-configurations
1960 :group 'LaTeX
c8de140b 1961 :type '(choice
3666daf6
CD
1962 (const :tag "No plug-ins" nil)
1963 (const :tag "All possible plug-ins" t)
1964 (list
1965 :tag "Individual choice"
1966 :value (t t t t t)
1967 (boolean :tag "supply label in new sections and environments")
1968 (boolean :tag "supply argument for macros like `\\label' ")
1969 (boolean :tag "supply argument for macros like `\\ref' ")
1970 (boolean :tag "supply argument for macros like `\\cite' ")
4f595e15 1971 (boolean :tag "supply argument for macros like `\\index' "))))
1a9461d0
CD
1972
1973(defcustom reftex-allow-detached-macro-args nil
fb7ada5f 1974 "Non-nil means, allow arguments of macros to be detached by whitespace.
1a9461d0
CD
1975When this is t, `aaa' will be considered as argument of \\bb in the following
1976construct: \\bbb [xxx] {aaa}."
1977 :group 'reftex-miscellaneous-configurations
1978 :type 'boolean)
1979
1980
1981(defcustom reftex-load-hook nil
1982 "Hook which is being run when loading reftex.el."
1983 :group 'reftex-miscellaneous-configurations
1984 :type 'hook)
1985
1986(defcustom reftex-mode-hook nil
1987 "Hook which is being run when turning on RefTeX mode."
1988 :group 'reftex-miscellaneous-configurations
1989 :type 'hook)
1990
3666daf6 1991
f541b8c6
MR
1992(provide 'reftex-vars)
1993
1a9461d0 1994;;; reftex-vars.el ends here