Mercurial > emacs
annotate lisp/textmodes/reftex.el @ 19660:fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
(reftex-show-commentary): New function.
(reftex-label-alist): Prefix may contain % escapes. Nth macro
argument may be context. May give two different context methods.
(reftex-default-label-alist-entries): Customization type changed.
(reftex-label-menu-flags): Extra flag for searches.
(reftex-cite-format): Changed completely, % escapes are now used.
(reftex-comment-citations): New variable.
(reftex-cite-comment-format): New variable.
(reftex-cite-punctuation): New variable.
(reftex-make-master-buffer): Changed name of master buffer,
removed interactive. Runs a hook on the buffer. Interprete
TEXINPUTS environment variable. Allow naked argument for \input.
Master buffer is now in fundamental mode.
(reftex-access-scan-info): Name of master buffer changed.
(reftex-section-regexp): Is now computed from section levels,
not set independantly.
(reftex-section-levels): Made customizable.
(reftex-label): Interpret % escapes in prefix. Use label format if given.
(reftex-replace-prefix-escapes): New function.
(reftex-uniquify-label): New function.
(reftex-next-label-number): Function definition removed.
(reftex-reference): Use reftex-uniquify-label.
Allow more general label commands.
(reftex-offer-label-menu):
Interpret new flag in reftex-label-menu-flags.
(reftex-make-and-insert-label-list): Use text properties to record label index.
(reftex-find-nearby-label): Allow more general label commands.
(reftex-scan-buffer-for-labels): Allow more general label commands.
(reftex-init-section-numbers): New function.
(reftex-allow-for-ctrl-m): New function.
(reftex-label-info-update): Allow more general label commands.
(reftex-label-info): New parameter derive.
(reftex-short-context): Interprete integer parse as nth arg of macro.
(reftex-nth-parens-substring): New function.
(reftex-select-item): Interprete the new 'cnt text property.
(reftex-pop-to-label): Allow more general label commands.
(reftex-nicify-text): Allow more general label commands.
(reftex-toc): Remember previous window configuration. Use text
properties to store info. Bind mouse-2.
(reftex-make-master-buffer): New Hook.
(reftex-last-window-height): New variable.
(reftex-toc-show-help): New function.
(reftex-toc-help): New constant.
(reftex-nearest-section): Use text properties to store info.
(reftex-empty-toc-buffer): New function.
(reftex-re-enlarge): New function.
(reftex-toc-goto-line): New function.
(reftex-toc-mouse-goto-line-and-hide): New function.
(reftex-cite-format-builtin): New constant.
(reftex-cite-format-default): Constant removed.
(reftex-cite-format-1-author-simple): Constant removed.
(reftex-cite-format-2-authors): Constant removed.
(reftex-get-bib-names): New function.
(reftex-get-bib-authors) Function removed.
(reftex-format-bib-entry): Use now reftex-get-bib-names.
(reftex-citation): Completely rewritten. Offers selection of
different cite macros first, then the reference menu. Works with
the various new variables mentioned above. Accept the `a' key to
use all selected citations.
(reftex-insert-bib-matches): New function.
(reftex-format-citation): Now interpretes % escapes.
(reftex-select-item): Emulate a search in the menu buffer.
Interpret the 'cnt text property.
(reftex-view-crossref): Allow more general label, cite and ref macros.
(reftex-highlight-overlays): Add third overlay for search
in menu buffer.
(reftex-label-alist-builtin): xalignat and xxalignat environments
added. Slightly reorganized.
(reftex-reset-scanning-information): Just empty *toc* buffer, do
not kill it.
(reftex-compute-ref-cite-tables): Read the new options in
`reftex-label-alist' and store them. Calculate the section regexp.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 01 Sep 1997 18:11:35 +0000 |
parents | 0ed97be54a28 |
children | c00f010468c2 |
rev | line source |
---|---|
18123 | 1 ;; reftex.el --- Minor mode for doing \label, \ref and \cite in LaTeX |
18220
36a61aa59b9d
(tex-main-file, outline-minor-mode): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
18219
diff
changeset
|
2 |
18050 | 3 ;; Copyright (c) 1997 Free Software Foundation, Inc. |
4 | |
5 ;; Author: Carsten Dominik <dominik@strw.LeidenUniv.nl> | |
6 ;; Keywords: tex | |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
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 | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
24 | |
25 ;;--------------------------------------------------------------------------- | |
26 ;; | |
27 ;;; Commentary: | |
28 ;; | |
18123 | 29 ;; RefTeX is a minor mode with distinct support for \ref, \label and |
30 ;; \cite commands in (multi-file) LaTeX documents. | |
18050 | 31 ;; Labels are created semi-automatically. Definition context of labels is |
32 ;; provided when creating a reference. Citations are simplified with | |
33 ;; efficient database lookup. | |
34 ;; | |
35 ;; To turn RefTeX Minor Mode on and off in a particular buffer, use | |
36 ;; `M-x reftex-mode'. | |
37 ;; | |
38 ;; To turn on RefTeX Minor Mode for all LaTeX files, add one of the | |
39 ;; following lines to your .emacs file: | |
40 ;; | |
41 ;; (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode | |
42 ;; (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode | |
43 ;; | |
44 ;; For key bindings, see further down in this documentation. | |
45 ;; | |
46 ;;--------------------------------------------------------------------------- | |
47 ;; | |
48 ;; OVERVIEW | |
49 ;; | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
50 ;; 1. USING \label AND \ref. Labels and references are one of the |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
51 ;; strong points of LaTeX. But, in documents with hundreds of |
18050 | 52 ;; equations, figures, tables etc. it becomes quickly impossible to |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
53 ;; find good label names and to actually remember them. Then, also |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
54 ;; completion of labels in not enough. One actually needs to see the |
18050 | 55 ;; context of the label definition to find the right one. |
56 ;; | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
57 ;; - RefTeX distinguishes labels for different environments. It |
18050 | 58 ;; always knows if a certain label references a figure, table |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
59 ;; etc.. You can configure RefTeX to recognize any additional |
18050 | 60 ;; labeled environments you might have defined yourself. |
61 ;; | |
62 ;; - RefTeX defines automatically unique labels. Type `C-c (' | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
63 ;; (reftex-label) to insert a label at point. RefTeX will either |
18050 | 64 ;; - derive a label from context (default for section labels) |
65 ;; - insert a simple label consisting of a prefix and a number | |
66 ;; (default for equations and enumerate items) or | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
67 ;; - prompt for a label string (figures and tables). |
18050 | 68 ;; Which labels are created how can be controlled with the variable |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
69 ;; `reftex-insert-label-flags'. |
18050 | 70 ;; |
71 ;; - Referencing labels is a snap and I promise you'll love it. | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
72 ;; In order to make a reference, type `C-c )' (`reftex-reference'). |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
73 ;; This shows an outline of the document with all labels of a |
18050 | 74 ;; certain type (figure, equation,...) and context of the label |
18123 | 75 ;; definition. Selecting one of the labels inserts a \ref macro |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
76 ;; into the original buffer. Online help during the selection is |
18050 | 77 ;; available with `?'. |
78 ;; | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
79 ;; 2. CITATIONS. After typing `C-c [' (`reftex-citation'), RefTeX will |
18050 | 80 ;; let you specify a regexp to search in current BibTeX database files |
81 ;; (as specified in the \bibliography command) and pull out a formatted | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
82 ;; list of matches for you to choose from. The list is *formatted* and |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
83 ;; thus much easier to read than the raw database entries. It can also |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
84 ;; be sorted. The text inserted into the buffer is by default just |
18050 | 85 ;; `\cite{KEY}', but can also contain author names and the year in a |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
86 ;; configurable way. See documentation of the variable |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
87 ;; `reftex-cite-format'. |
18050 | 88 ;; |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
89 ;; 3. TABLE OF CONTENTS. Typing `C-c =' (`reftex-toc') will show a table |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
90 ;; of contents of the document. From that buffer, you can jump quickly |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
91 ;; to every part of your document. This is similar to imenu, only it |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
92 ;; works for entire multifile documents and uses the keyboard rather |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
93 ;; than the mouse. The initial version of this function was contributed |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
94 ;; by Stephen Eglen. |
18050 | 95 ;; |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
96 ;; 4. MULTIFILE DOCUMENTS are fully supported by RefTeX. Such documents |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
97 ;; consist of a master file and many other files being included via |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
98 ;; \input or \include. (La)TeX source files included from another file |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
99 ;; should specify the name of the top level master file with a `file |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
100 ;; variable' (see the Emacs documentation on file variables for details: |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
101 ;; [Emacs/Customization/Variables/File Variables]). With AUCTeX, this |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
102 ;; variable is called `TeX-master'. The Emacs (La)TeX modes use |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
103 ;; `tex-main-file' instead. RefTeX will check for both. Check the |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
104 ;; documentation of your (La)TeX modes on how to specify the master |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
105 ;; file. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
106 ;; RefTeX knows about all files related to a document via \input and |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
107 ;; \include. It provides functions to run regular expression searches |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
108 ;; and replaces over the entire document and to create a TAGS file. |
18050 | 109 ;; |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
110 ;; 5. DOCUMENT PARSING. RefTeX needs to parse the document in order to find |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
111 ;; labels and other information. It will do it automatically once, when |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
112 ;; you start working with a document. If you need to enforce reparsing |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
113 ;; later, call any of the functions `reftex-citation', `reftex-label', |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
114 ;; `reftex-reference', `reftex-toc' with a raw C-u prefix. |
18050 | 115 ;; |
116 ;;------------------------------------------------------------------------- | |
117 ;; | |
118 ;; CONFIGURATION | |
119 ;; | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
120 ;; RefTeX contains configurable options which change the way it works. |
18050 | 121 ;; |
122 ;; Most importantly, RefTeX needs to be configured if you use labels to | |
123 ;; mark non-standard environments. RefTeX always understands LaTeX section | |
124 ;; commands and the following environments: figure, figure*, | |
125 ;; sidewaysfigure, table, table*, sidewaystable, equation, eqnarray, | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
126 ;; enumerate. For everythings else, it needs to be configured. |
18050 | 127 ;; |
128 ;; A good way to configure RefTeX is with the custom.el package by Per | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
129 ;; Abrahamsen, shipped with Emacs 20 and XEmacs 19.15. To do this, just |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
130 ;; say `M-x reftex-customize'. |
18050 | 131 ;; |
132 ;; Here is a complete list of the RefTeX configuration variables with | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
133 ;; their default settings. You could copy part of this list to your |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
134 ;; .emacs file and change whatever is necessary. Each variable has an |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
135 ;; extensive documentation string. Look it up for more information! |
18050 | 136 ;; |
137 ;; ;; Configuration Variables and User Options for RefTeX ------------------ | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
138 ;; ;; Support for \label and \ref ------------------------------------------ |
18050 | 139 ;; (setq reftex-label-alist nil) |
140 ;; (setq reftex-default-label-alist-entries '(Sideways LaTeX)) | |
141 ;; (setq reftex-use-text-after-label-as-context nil) | |
142 ;; ;; Label insertion | |
143 ;; (setq reftex-insert-label-flags '("s" "sft")) | |
144 ;; (setq reftex-derive-label-parameters '(3 20 t 1 "-" | |
145 ;; ("the" "on" "in" "off" "a" "for" "by" "of" "and" "is"))) | |
146 ;; (setq reftex-label-illegal-re "[\000-\040\177-\377\\\\#$%&~^_{}]") | |
147 ;; (setq reftex-abbrev-parameters '(4 2 "^saeiou" "aeiou")) | |
148 ;; ;; Label referencing | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
149 ;; (setq reftex-label-menu-flags '(t t nil nil nil nil t)) |
18050 | 150 ;; (setq reftex-guess-label-type t) |
151 ;; ;; BibteX citation configuration ---------------------------------------- | |
152 ;; (setq reftex-bibpath-environment-variables '("BIBINPUTS" "TEXBIB")) | |
153 ;; (setq reftex-bibfile-ignore-list nil) | |
154 ;; (setq reftex-sort-bibtex-matches 'reverse-year) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
155 ;; (setq reftex-cite-format 'default) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
156 ;; (setq reftex-comment-citations nil) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
157 ;; (setq reftex-cite-comment-format |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
158 ;; "%% %2a %y, %j %v, %P, %e: %b, %u, %s %<\n") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
159 ;; (setq reftex-cite-punctuation '(", " " \\& " " {\\it et al.}")) |
18050 | 160 ;; ;; Table of contents configuration -------------------------------------- |
161 ;; (setq reftex-toc-follow-mode nil) | |
162 ;; ;; Miscellaneous configurations ----------------------------------------- | |
163 ;; (setq reftex-extra-bindings nil) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
164 ;; (setq reftex-plug-into-AUCTeX nil) |
18050 | 165 ;; (setq reftex-use-fonts t) |
166 ;; (setq reftex-keep-temporary-buffers t) | |
167 ;; (setq reftex-auto-show-entry t) | |
168 ;; | |
169 ;; CONFIGURATION EXAMPLES: | |
170 ;; ======================= | |
171 ;; | |
172 ;; Suppose you are working with AMS-LaTeX amsmath package (with its math | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
173 ;; environments like `align', `multline' etc.). Here is how you would |
18050 | 174 ;; configure RefTeX to recognize these environments: |
175 ;; | |
176 ;; (setq reftex-label-alist '(AMSTeX)) | |
177 ;; | |
178 ;; This is very easy since RefTeX has builtin support for AMS-LaTeX. | |
179 ;; Suppose, however, you are also | |
180 ;; | |
181 ;; - using "\newtheorem" in LaTeX in order to define two new environments | |
182 ;; "Theorem" and "Axiom" like this: | |
183 ;; | |
184 ;; \newtheorem{axiom}{Axiom} | |
185 ;; \newtheorem{theorem}{Theorem} | |
186 ;; | |
187 ;; - making your figures not directly with the figure environment, but with | |
188 ;; a macro like | |
189 ;; | |
190 ;; \newcommand{\myfig}[4][tbp]{ | |
191 ;; \begin{figure}[#1] | |
192 ;; \epsimp[#4]{#2} | |
193 ;; \caption{#3} | |
194 ;; \end{figure}} | |
195 ;; | |
196 ;; which would be called like | |
197 ;; | |
198 ;; \myfig{filename}{\label{fig:13} caption text}{1} | |
199 ;; | |
200 ;; Here is how to tell RefTeX to also recognize Theorem and Axiom as | |
201 ;; labeled environments, and that any labels defined inside the \myfig | |
202 ;; macro are figure labels: | |
203 ;; | |
204 ;; (setq reftex-label-alist | |
205 ;; '(AMSTeX | |
206 ;; ("axiom" ?a "ax:" "~\\ref{%s}" nil ("Axiom" "Ax.")) | |
207 ;; ("theorem" ?h "thr:" "~\\ref{%s}" t ("Theorem" "Theor." "Th.")) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
208 ;; ("\\myfig" ?f "fig:" nil 2))) |
18050 | 209 ;; |
210 ;; The type indicator characters ?a and ?h are used for prompts when | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
211 ;; RefTeX queries for a label type. Note that "h" was chosen for "theorem" |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
212 ;; since "t" is already taken by "table". Note that also "s", "f", "e", "n" |
18050 | 213 ;; are taken by the standard environments. |
214 ;; The automatic labels for Axioms and Theorems will look like "ax:23" or | |
215 ;; "thr:24". | |
216 ;; The "\ref{%s}" is a format string indicating how to insert references to | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
217 ;; these labels. The nil format in the \myfig entry means to use the same |
18050 | 218 ;; format as other figure labels. |
219 ;; The next item indicates how to grab context of the label definition. | |
220 ;; - t means to get it from a default location (from the beginning of a \macro | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
221 ;; or after the \begin statement). t is *not* a good choice for eqnarray |
18050 | 222 ;; and similar environments. |
223 ;; - nil means to use the text right after the label definition. | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
224 ;; - 2 means grab the 2nd macro argument: \myfig{xxx}{THIS IS CONTEXT}{1} |
18050 | 225 ;; - For more complex ways of getting context, see the docstring of |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
226 ;; `reftex-label-alist'. |
18050 | 227 ;; The strings at the end of each entry are used to guess the correct label |
228 ;; type from the word before point when creating a reference. E.g. if you | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
229 ;; write: "As we have shown in Theorem" and then press `C-)', RefTeX will |
18050 | 230 ;; know that you are looking for a Theorem label and restrict the labels in |
231 ;; the menu to only these labels without even asking. | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
232 ;; See also the documentation string of the variable `reftex-label-alist'. |
18050 | 233 ;; |
234 ;; Depending on how you would like the label insertion and selection for the | |
235 ;; new environments to work, you might want to add the letters "a" and "h" | |
236 ;; to some of the flags in the following variables: | |
237 ;; | |
238 ;; reftex-insert-label-flags | |
239 ;; reftex-label-menu-flags | |
240 ;; | |
241 ;; The individual flags in these variables can be set to t or nil to enable or | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
242 ;; disable the feature for all label types. They may also contain a string of |
18050 | 243 ;; label type letters in order to turn on the feature for those types only. |
244 ;; | |
245 ;; ----- | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
246 ;; If you are writing in a language different from English you might want to |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
247 ;; add magic words for that language. Here is a German example: |
18050 | 248 ;; |
249 ;; (setq reftex-label-alist | |
250 ;; '((nil ?s nil nil nil ("Kapitel" "Kap." "Abschnitt" "Teil")) | |
251 ;; (nil ?e nil nil nil ("Gleichung" "Gl.")) | |
252 ;; (nil ?t nil nil nil ("Tabelle")) | |
253 ;; (nil ?f nil nil nil ("Figur" "Abbildung" "Abb.")) | |
254 ;; (nil ?n nil nil nil ("Punkt")))) | |
255 ;; | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
256 ;; Using nil as first item in each entry makes sure that this entry does |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
257 ;; not replace the original entry for that label type, but just adds magic |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
258 ;; words. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
259 ;; |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
260 ;; ----- |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
261 ;; |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
262 ;; By default, citations are inserted simply as \cite{KEY}. You can have |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
263 ;; more complex citation commands with many available packages, most |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
264 ;; notably the harvard and natbib packages. RefTeX can be configured to |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
265 ;; support these and other styles by setting the variable reftex-cite-format. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
266 ;; E.g., for the natbib package you would use |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
267 ;; |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
268 ;; (setq reftex-cite-format 'natbib) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
269 ;; |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
270 ;; This can also be done as a file variable. For the full list of builtin |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
271 ;; options, try `M-x customize-variable RET reftex-cite-format RET'. |
18050 | 272 ;; |
273 ;; HOOKS | |
274 ;; ----- | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
275 ;; - Loading reftex.el runs the hook `reftex-load-hook'. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
276 ;; - Turning on reftex-mode runs `reftex-mode-hook'. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
277 ;; - Creating the master buffer runs `reftex-make-master-buffer-hook' |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
278 ;; on the master buffer just before parsing starts. |
18050 | 279 ;; |
280 ;;------------------------------------------------------------------------- | |
281 ;; | |
282 ;; KEY BINDINGS | |
283 ;; | |
284 ;; All important functions of RefTeX can be reached from its menu which | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
285 ;; is installed in the menu bar as "Ref" menu. Only the more frequently used |
18050 | 286 ;; functions have key bindings. |
287 ;; | |
288 ;; Here is the default set of keybindings from RefTeX. | |
289 ;; | |
290 ;; C-c = reftex-toc | |
291 ;; C-c ( reftex-label | |
292 ;; C-c ) reftex-reference | |
293 ;; C-c [ reftex-citation | |
294 ;; C-c & reftex-view-crossref | |
295 ;; | |
296 ;; I've used these bindings in order to avoid interfering with AUCTeX's | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
297 ;; settings. Personally, I also bind some functions in the C-c LETTER |
18050 | 298 ;; map for easier access: |
299 ;; | |
300 ;; C-c t reftex-toc | |
301 ;; C-c l reftex-label | |
302 ;; C-c r reftex-reference | |
303 ;; C-c c reftex-citation | |
304 ;; C-c v reftex-view-crossref | |
305 ;; C-c s reftex-search-document | |
306 ;; C-c g reftex-grep-document | |
307 ;; | |
308 ;; If you want to copy those as well, set in your .emacs file: | |
309 ;; | |
310 ;; (setq reftex-extra-bindings t) | |
311 ;; | |
312 ;; It is possible to bind the function for viewing cross references to a | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
313 ;; mouse event. Something like the following in .emacs will do the trick: |
18050 | 314 ;; |
315 ;; (add-hook 'reftex-load-hook | |
316 ;; '(lambda () | |
317 ;; (define-key reftex-mode-map [(alt mouse-1)] | |
318 ;; 'reftex-mouse-view-crossref))) | |
319 ;; | |
320 ;;------------------------------------------------------------------------- | |
321 ;; | |
322 ;; RELATED PACKAGES | |
323 ;; | |
324 ;; AUCTeX | |
325 ;; ------ | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
326 ;; If you are writing TeX or LaTeX documents with Emacs, you should have |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
327 ;; a look at AUCTeX, the definitive package to work with TeX and LaTeX. |
18050 | 328 ;; Information on AUCTeX can be found here: |
329 ;; | |
330 ;; http://www.sunsite.auc.dk/auctex/ | |
331 ;; | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
332 ;; Instead of using the RefTeX functions described above directly, you |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
333 ;; can also use them indirectly through AUCTeX (>9.7p). RefTeX provides |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
334 ;; several interface functions which can be used as replacement for |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
335 ;; corresponding AUCTeX functions dealing with labels and citations. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
336 ;; In this way you can work normally with AUCTeX and use RefTeX |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
337 ;; internals to create and complete labels and citation keys. |
18050 | 338 ;; |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
339 ;; `reftex-label' can be used as the `LaTeX-label-function' which does |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
340 ;; label insertion when new environments are created with C-c C-e. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
341 ;; |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
342 ;; `reftex-arg-label', `reftex-arg-ref' and `reftex-arg-cite' can replace |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
343 ;; the corresponding `TeX-arg-...' functions. E.g. when you insert a |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
344 ;; label macro with `C-c RET label RET', RefTeX will be transparently used |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
345 ;; to create the label. |
18050 | 346 ;; |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
347 ;; In order to plug all 4 functions into AUCTeX, use in .emacs: |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
348 ;; |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
349 ;; (setq reftex-plug-into-AUCTeX t) |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
350 ;; |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
351 ;; You may also choose to plug in only some of these functions. See |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
352 ;; the doc string of `reftex-plug-into-AUCTeX'. |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
353 ;; |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
354 ;; AUCTeX can support RefTeX via style files. A style file may contain |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
355 ;; calls to `reftex-add-to-label-alist' which defines additions to |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
356 ;; `reftex-label-alist'. The argument taken by this function must have |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
357 ;; the same format as `reftex-label-alist'. The `amsmath.el' style file |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
358 ;; of AUCTeX (>9.7p) for example contains the following: |
18050 | 359 ;; |
18219
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
360 ;; (TeX-add-style-hook "amsmath" |
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
361 ;; (function |
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
362 ;; (lambda () |
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
363 ;; (if (featurep 'reftex) |
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
364 ;; (reftex-add-to-label-alist '(AMSTeX)))))) |
18050 | 365 ;; |
18219
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
366 ;; while a package `myprop' defining a proposition environment with |
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
367 ;; \newtheorem might use |
18050 | 368 ;; |
18219
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
369 ;; (TeX-add-style-hook "myprop" |
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
370 ;; (function |
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
371 ;; (lambda () |
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
372 ;; (if (featurep 'reftex) |
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
373 ;; (reftex-add-to-label-alist |
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
374 ;; '(("proposition" ?p "prop:" "~\\ref{%s}" t |
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
375 ;; ("Proposition" "Prop.")))))))) |
18050 | 376 ;; |
377 ;; Bib-cite.el | |
378 ;; ----------- | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
379 ;; Once you have written a document with labels, refs and citations, |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
380 ;; it can be nice to read such a file like a hypertext document. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
381 ;; RefTeX has some support for that (`reftex-view-crossref', |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
382 ;; `reftex-search-document'). A more elegant interface with mouse |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
383 ;; support and links into Hyperbole is provided (among other things) |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
384 ;; by Peter S. Galbraith's `bib-cite.el'. There is some overlap in the |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
385 ;; functionalities of Bib-cite and RefTeX. Bib-cite.el comes bundled |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
386 ;; with AUCTeX. You can also get the latest version from |
18050 | 387 ;; |
388 ;; ftp://ftp.phys.ocean.dal.ca/users/rhogee/elisp/bib-cite.el | |
389 ;; | |
390 ;;------------------------------------------------------------------------- | |
391 ;; | |
392 ;; PERFORMANCE ISSUES | |
393 ;; | |
394 ;; 1. RefTeX will load other parts of a multifile document as well as BibTeX | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
395 ;; database files for lookup purposes. These buffers are kept, so that |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
396 ;; subsequent lookup in the same files is fast. For large documents and |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
397 ;; large BibTeX databases, this can use up a lot of memory. If you have |
18050 | 398 ;; more time than memory, try the following option, which will remove |
399 ;; buffers created for lookup after use. | |
400 ;; | |
401 ;; (setq reftex-keep-temporary-buffers nil) | |
402 ;; | |
403 ;; 2. Parsing the document for labels and their context can be slow. | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
404 ;; Therefore, RefTeX does it just once automatically. Further parsing |
18050 | 405 ;; happens only on user request |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
406 ;; - with a raw C-u prefix arg to any of the functions `reftex-label', |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
407 ;; `reftex-reference', `reftex-citation', `reftex-toc'. |
18050 | 408 ;; - with the `r' key from the label selection menu or the *toc* buffer. |
409 ;; | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
410 ;; *** If you use `reftex-label' to create labels, the list will be |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
411 ;; *** updated internally, so that no extra parsing is required. |
18050 | 412 ;; |
413 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
414 ;; | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
415 ;; KNOWN BUGS AND WORK-AROUNDS |
18050 | 416 ;; |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
417 ;; o If you change `reftex-label-alist' in an editing session, you need to |
18050 | 418 ;; reset reftex with `M-x reftex-reset-mode' in order to make these |
419 ;; changes effective. Changes introduced with the function | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
420 ;; `reftex-add-to-label-alist' as well as changes applied from the |
18050 | 421 ;; customization buffer automatically trigger a reset. |
422 ;; | |
423 ;; o At times the short context shown by RefTeX may not be what you want. | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
424 ;; In particular, eqnarray environments can be difficult to parse. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
425 ;; RefTeX's default behavior for eqnarrays is to scan backwards to either |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
426 ;; a double backslash or the beginning of the environment. If this gives |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
427 ;; unsatisfactory results, make it a habit to place the label *before* |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
428 ;; each equation |
18050 | 429 ;; |
430 ;; \begin{eqnarray} | |
431 ;; \label{eq:1} | |
432 ;; E = \gamma m c^2 \\ | |
433 ;; \label{eq:2} | |
434 ;; \gamma = \sqrt{1-v^2/c^2} | |
435 ;; \end{eqnarray} | |
436 ;; | |
437 ;; and turn off parsing for context in equation and eqnarray environments | |
438 ;; with | |
439 ;; | |
440 ;; (setq reftex-use-text-after-label-as-context "e"). | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
441 ;; |
18050 | 442 ;; o RefTeX keeps only one global copy of the configuration variables. |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
443 ;; Also, any additions from style files go into a global variable. |
18050 | 444 ;; Practically, this should not be a problem. Theoretically, it could |
445 ;; give conflicts if two documents used environments with identical | |
446 ;; names, but different associated label types. | |
447 ;; | |
448 ;; o Input, include, bibliography and section statements have to be first | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
449 ;; on a line (except for white space) in order to be seen by RefTeX. |
18050 | 450 ;; |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
451 ;; o When the document is scanned, RefTeX creates a large "master" buffer |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
452 ;; containing the entire document instead of scanning the individual |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
453 ;; files one by one. I hope to change this eventually. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
454 ;; |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
455 ;; o Creating the master buffer bypasses `find-file-hook' as well as |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
456 ;; TeX/LaTeX mode hooks for efficiency reasons. If any of the relevant |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
457 ;; hooks contains functions filtering (La)TeX files (e.g. isotex), these |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
458 ;; functions should go into `reftex-make-master-buffer-hook' as well. |
18050 | 459 ;; |
460 ;; o If you have two identical section headings in the same file, | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
461 ;; `reftex-toc' will only let you jump to the first one because it searches |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
462 ;; for the section heading from the beginning of the file. You can work |
18050 | 463 ;; around this by changing one of the section titles in a way LaTeX does |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
464 ;; not see, e.g. with extra white space. RefTeX will distinguish |
18050 | 465 ;; \section{Introduction} from \section{ Introduction}. |
466 ;; | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
467 ;; o RefTeX needs a \label macro to identify a label during parsing. Some |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
468 ;; packages, however, define environments and macros which require a naked |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
469 ;; label as argument. This is currently not possible with RefTeX. It |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
470 ;; will be in version 3.00. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
471 ;; |
18050 | 472 ;; o RefTeX sees also labels in regions commented out and will refuse to |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
473 ;; make duplicates of such a label. This is considered to be a feature. |
18050 | 474 ;; |
475 ;; o When RefTeX tries to show a window full of context from inside a | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
476 ;; section hidden with `outline-minor-mode', it will unhide that section. |
18050 | 477 ;; This change will not be reversed automatically. |
478 ;; | |
479 ;;--------------------------------------------------------------------------- | |
480 ;; | |
481 ;; TO DO | |
482 ;; | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
483 ;; Rewriting the parser so that it can parse the file without making a |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
484 ;; master buffer, save parsing information and reparse only parts of |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
485 ;; the document. This will make RefTeX better suited for very large |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
486 ;; projects. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
487 ;; |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
488 ;; Deal with naked labels. |
18050 | 489 ;; |
490 ;;--------------------------------------------------------------------------- | |
491 ;; | |
492 ;; AUTHOR | |
493 ;; | |
494 ;; Carsten Dominik <dominik@strw.LeidenUniv.nl> | |
495 ;; | |
496 ;; with contributions from Stephen Eglen | |
497 ;; | |
498 ;; The newest version of RefTeX can be found at | |
499 ;; | |
500 ;; http://www.strw.leidenuniv.nl/~dominik/Tools/ | |
501 ;; ftp://strw.leidenuniv.nl/pub/dominik/ | |
502 ;; | |
503 ;; THANKS TO: | |
504 ;; --------- | |
505 ;; At least the following people have invested time to test and bug-fix | |
506 ;; reftex.el. Some have send patches for fixes or new features. | |
507 ;; | |
508 ;; Stephen Eglen <stephene@cogs.susx.ac.uk> | |
509 ;; F.E.Burstall <F.E.Burstall@maths.bath.ac.uk> | |
510 ;; Karl Eichwalder <ke@ke.Central.DE> | |
511 ;; Laurent Mugnier <mugnier@onera.fr> | |
512 ;; Rory Molinari <molinari@yunt.math.lsa.umich.edu> | |
513 ;; Soren Dayton <csdayton@cs.uchicago.edu> | |
514 ;; Daniel Polani <polani@Informatik.Uni-Mainz.DE> | |
515 ;; Allan Strand <astrand@trillium.NMSU.Edu> | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
516 ;; Adrian Lanz <lanz@waho.ethz.ch> |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
517 ;; Jan Vroonhof <vroonhof@math.ethz.ch> |
18050 | 518 ;; |
519 ;; The view crossref feature was inspired by the similar function in | |
520 ;; Peter S. Galbraith's bib-cite.el. | |
521 ;; | |
522 ;; Finally thanks to Uwe Bolick <bolick@physik.tu-berlin.de> who first | |
523 ;; got me (some years ago) into supporting LaTeX labels and references | |
524 ;; with an Editor (which was MicroEmacs at the time). | |
18219
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
525 ;; |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
526 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
527 ;; |
18050 | 528 |
529 ;;; Code: | |
530 | |
531 ;; Stuff that needs to be there when we use defcustom | |
532 ;; -------------------------------------------------- | |
533 | |
534 (require 'custom) | |
535 | |
536 (defvar reftex-tables-dirty t | |
537 "Flag showing if tables need to be re-computed.") | |
538 | |
539 (eval-and-compile | |
540 (defun reftex-set-dirty (symbol value) | |
541 (setq reftex-tables-dirty t) | |
542 (set symbol value))) | |
543 | |
544 ;;; Begin of Configuration Section ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
545 | |
546 ;; Configuration Variables and User Options for RefTeX ------------------ | |
547 | |
548 (defgroup reftex nil | |
549 "LaTeX label and citation support." | |
550 :tag "RefTeX" | |
551 :link '(url-link :tag "Home Page" "http://strw.leidenuniv.nl/~dominik/Tools/") | |
552 :prefix "reftex-" | |
553 :group 'tex) | |
554 | |
555 (defun reftex-customize () | |
556 "Call the customize function with reftex as argument." | |
557 (interactive) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
558 ;; Depending on the customize version we can call different functions. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
559 (cond |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
560 ((fboundp 'customize-browse) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
561 (customize-browse 'reftex)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
562 ((fboundp 'customize-group) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
563 (customize-group 'reftex)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
564 (t |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
565 (customize 'reftex)))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
566 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
567 (defun reftex-show-commentary () |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
568 "Use the finder to view the file documentation from `reftex.el'." |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
569 (interactive) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
570 (require 'finder) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
571 (finder-commentary "reftex.el")) |
18050 | 572 |
18123 | 573 ;; Support for \label and \ref -------------------------------------- |
18050 | 574 |
575 (defgroup reftex-label-support nil | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
576 "Support for creation, insertion and referencing of labels in LaTeX." |
18050 | 577 :group 'reftex) |
578 | |
579 (defgroup reftex-defining-label-environments nil | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
580 "Definition of environments and macros to do with label." |
18050 | 581 :group 'reftex-label-support) |
582 | |
583 (defcustom reftex-label-alist nil | |
18123 | 584 "Alist with information on environments for \\label-\\ref use. |
18220
36a61aa59b9d
(tex-main-file, outline-minor-mode): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
18219
diff
changeset
|
585 See the definition of `reftex-label-alist-builtin' for examples. This variable |
18050 | 586 should define additions and changes to the default. The only things you MUST |
18220
36a61aa59b9d
(tex-main-file, outline-minor-mode): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
18219
diff
changeset
|
587 NOT change is that `?s' is the type indicator for section labels and SPACE is |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
588 for the `any' label type. These are hard-coded at other places in the code. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
589 |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
590 Changes to this variable after RefTeX has been loaded become only |
18050 | 591 effective when RefTeX is reset with \\[reftex-reset-mode]. |
592 | |
593 Each list entry is a list describing an environment or macro carrying a | |
18220
36a61aa59b9d
(tex-main-file, outline-minor-mode): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
18219
diff
changeset
|
594 label. The elements of each list entry are: |
18050 | 595 |
596 0. Name of the environment (like \"table\") or macro (like \"\\\\myfig\"). | |
597 Special names: `section' for section labels, `any' to define a group | |
598 which contains all labels. | |
599 This may also be nil if this entry is only meant to change some settings | |
600 associated with the type indicator character (see below). | |
601 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
602 1. Type indicator character, like `?t'. |
18050 | 603 The type indicator is a single character used in prompts for |
18220
36a61aa59b9d
(tex-main-file, outline-minor-mode): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
18219
diff
changeset
|
604 label types. It must be a printable character. The same character |
18050 | 605 may occur several times in this list, to cover cases in which different |
606 environments carry the same label type (like equation and eqnarray). | |
607 | |
608 2. Label prefix string, like \"tab:\". | |
18220
36a61aa59b9d
(tex-main-file, outline-minor-mode): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
18219
diff
changeset
|
609 The prefix is a short string used as the start of a label. It may be the |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
610 empty string. If `nil', a prefix will be constructed from the typekey. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
611 The prefix may contain the following `%' escapes: |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
612 %f Current file name with directory and extension stripped. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
613 %F Current file name relative to directory of master file. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
614 %u User login name, on systems which support this. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
615 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
616 Example: In a file `intro.tex', \"eq:%f:\" will become \"eq:intro:\"). |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
617 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
618 3. Format string for reference insert in buffer. `%s' will be replaced by |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
619 the label. |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
620 When the format starts with `~', whitespace before point will be removed |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
621 so that the reference cannot be separated from the word before it. |
18050 | 622 |
623 4. Indication on how to find the short context. | |
18220
36a61aa59b9d
(tex-main-file, outline-minor-mode): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
18219
diff
changeset
|
624 - If nil, use the text following the \\label{...} macro. |
36a61aa59b9d
(tex-main-file, outline-minor-mode): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
18219
diff
changeset
|
625 - If t, use |
18050 | 626 - text following the \\begin{...} statement of environments |
627 (not a good choice in in eqnarray or enumerate environments!) | |
628 - the section heading for section labels. | |
629 - the begin of the macro for macros. | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
630 - If an integer, use the nth argument of the macro. If there are less |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
631 than n arguments (parenthesis pairs), use text after the last one. |
18220
36a61aa59b9d
(tex-main-file, outline-minor-mode): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
18219
diff
changeset
|
632 - If a string, use as regexp to search *backward* from the label. Context |
36a61aa59b9d
(tex-main-file, outline-minor-mode): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
18219
diff
changeset
|
633 is then the text following the end of the match. E.g. putting this to |
18050 | 634 \"\\\\\\\\caption{\" will use the beginning of the caption in a figure |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
635 or table environment. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
636 \"\\\\\\\\begin{eqnarray}\\\\|\\\\\\\\\\\\\\\\\" works for eqnarrays. |
18050 | 637 - If a function, call this function with the name of the environment/macro |
18220
36a61aa59b9d
(tex-main-file, outline-minor-mode): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
18219
diff
changeset
|
638 as argument. On call, point will be just after the \\label macro. The |
36a61aa59b9d
(tex-main-file, outline-minor-mode): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
18219
diff
changeset
|
639 function is expected to return a suitable context string. It should |
18050 | 640 throw an exception (error) when failing to find context. |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
641 As an example, here is a function returning the 10 chars following |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
642 the label macro as context: |
18050 | 643 |
644 (defun my-context-function (env-or-mac) | |
645 (if (> (point-max) (+ 10 (point))) | |
646 (buffer-substring (point) (+ 10 (point))) | |
647 (error \"Buffer too small\"))) | |
648 | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
649 Label context is used in two ways by RefTeX: For display in the label |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
650 menu, and to derive a label string. If you want to use a different |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
651 method for each of these, specify them as a dotted pair. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
652 E.g. `(nil . t)' uses the text after the label (nil) for display, and |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
653 text from the default position (t) to derive a label string. This is |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
654 actually used for section labels. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
655 |
18220
36a61aa59b9d
(tex-main-file, outline-minor-mode): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
18219
diff
changeset
|
656 Setting the variable `reftex-use-text-after-label-as-context' to t |
36a61aa59b9d
(tex-main-file, outline-minor-mode): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
18219
diff
changeset
|
657 overrides the setting here. |
36a61aa59b9d
(tex-main-file, outline-minor-mode): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
18219
diff
changeset
|
658 |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
659 5. List of magic words which identify a reference to be of this type. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
660 If the word before point is equal to one of these words when calling |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
661 `reftex-reference', the label list offered will be automatically |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
662 restricted to labels of the correct type. |
18050 | 663 |
664 If the type indicator characters of two or more entries are the same, RefTeX | |
665 will use | |
666 - the first non-nil format and prefix | |
667 - the magic words of all involved entries. | |
668 | |
18220
36a61aa59b9d
(tex-main-file, outline-minor-mode): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
18219
diff
changeset
|
669 Any list entry may also be a symbol. If that has an association in |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
670 `reftex-label-alist-builtin', the cdr of that association is spliced into the |
18220
36a61aa59b9d
(tex-main-file, outline-minor-mode): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
18219
diff
changeset
|
671 list. See the AMSTeX configuration example in the comment section of |
36a61aa59b9d
(tex-main-file, outline-minor-mode): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents:
18219
diff
changeset
|
672 `reftex.el'." |
18050 | 673 :group 'reftex-defining-label-environments |
674 :set 'reftex-set-dirty | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
675 :type |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
676 '(repeat |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
677 :inline t |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
678 (radio |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
679 :value ("" ?a nil nil t nil) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
680 (choice |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
681 :tag "Builtin" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
682 :value AMSTeX |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
683 ;; Update here with: update-builtin-label-1 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
684 (const :tag "Sideways : Alias for -->rotating" Sideways) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
685 (const :tag "AMSTeX : Alias for -->amsmath" AMSTeX) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
686 (const :tag "amsmath : AMS math environments" amsmath) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
687 (const :tag "longtable: The longtable environment" longtable) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
688 (const :tag "rotating : Sidewaysfigure and table" rotating) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
689 (const :tag "subfigure: Subfigure environments/macro" subfigure) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
690 (const :tag "LaTeX : LaTeX default environments" LaTeX)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
691 (list :tag "Detailed custom entry" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
692 (choice :tag "Environment or \\macro " |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
693 (const :tag "Ignore, just use typekey" nil) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
694 (string "")) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
695 (character :tag "Typekey character " ?a) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
696 (choice :tag "Label prefix string " |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
697 (const :tag "Default" nil) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
698 (string :tag "String" "lab:")) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
699 (choice :tag "Label reference format" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
700 (const :tag "Default" nil) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
701 (string :tag "String" "~\\ref{%s}")) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
702 (choice :tag "Context" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
703 (choice |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
704 :tag "1 method" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
705 (const :tag "Default position" t) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
706 (const :tag "After label" nil) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
707 (number :tag "Macro arg nr" 1) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
708 (regexp :tag "Regexp" "") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
709 (symbol :tag "Function" my-func)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
710 (cons :tag "2 different methods" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
711 (choice |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
712 :tag " Display context " |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
713 (const :tag "Default position" t) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
714 (const :tag "After label" nil) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
715 (number :tag "Macro arg nr" 1) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
716 (regexp :tag "Regexp" "") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
717 (symbol :tag "Function" my-func)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
718 (choice |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
719 :tag " Derive label context" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
720 (const :tag "Default position" t) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
721 (const :tag "After label" nil) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
722 (number :tag "Macro arg nr" 1) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
723 (regexp :tag "Regexp" "") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
724 (symbol :tag "Function" my-func)))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
725 (repeat :tag "List of Magic Words" (string)))))) |
18050 | 726 |
727 (defcustom reftex-default-label-alist-entries '(Sideways LaTeX) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
728 "Default label alist specifications. LaTeX should be the last entry. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
729 This list describes the default label environments RefTeX should always use |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
730 in addition to the specifications in reftex-label-alist. It is probably a |
18050 | 731 mistake to remove the LaTeX symbol from this list. |
732 | |
18219
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
733 The options include: |
18050 | 734 LaTeX The standard LaTeX environments |
735 Sideways The sidewaysfigure and sidewaystable environments | |
736 AMSTeX The math environments in the AMS_LaTeX amsmath package | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
737 |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
738 For the full list of options, try |
18219
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
739 |
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
740 M-x customize-variable RET reftex-default-label-alist-entries RET." |
18050 | 741 :group 'reftex-defining-label-environments |
742 :set 'reftex-set-dirty | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
743 :type '(set |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
744 :indent 4 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
745 :inline t |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
746 :greedy t |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
747 ;; Update here with: update-builtin-label-2 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
748 (const :tag "Sideways : Alias for -->rotating" Sideways) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
749 (const :tag "AMSTeX : Alias for -->amsmath" AMSTeX) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
750 (const :tag "amsmath : AMS math environments" amsmath) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
751 (const :tag "longtable: The longtable environment" longtable) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
752 (const :tag "rotating : Sidewaysfigure and table" rotating) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
753 (const :tag "subfigure: Subfigure environments/macro" subfigure) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
754 (const :tag "LaTeX : LaTeX default environments" LaTeX)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
755 ) |
18050 | 756 |
757 (defcustom reftex-use-text-after-label-as-context nil | |
758 "*t means, grab context from directly after the \\label{..} macro. | |
759 This is the fastest method for obtaining context of the label definition, but | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
760 requires discipline when placing labels. Setting this variable to t takes |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
761 precedence over the individual settings in `reftex-label-alist'. |
18050 | 762 This variable may be set to t, nil, or a string of label type letters |
763 indicating the label types for which it should be true." | |
764 :group 'reftex-defining-label-environments | |
765 :set 'reftex-set-dirty | |
766 :type '(choice | |
767 (const :tag "on" t) (const :tag "off" nil) | |
768 (string :tag "Selected label types"))) | |
769 | |
770 ;; Label insertion | |
771 | |
772 (defgroup reftex-making-and-inserting-labels nil | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
773 "Options on how to create new labels." |
18050 | 774 :group 'reftex-label-support) |
775 | |
776 (defcustom reftex-insert-label-flags '("s" "sft") | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
777 "Flags governing label insertion. First flag DERIVE, second flag PROMPT. |
18050 | 778 |
779 If DERIVE is t, RefTeX will try to derive a sensible label from context. | |
780 A section label for example will be derived from the section heading. | |
781 The conversion of the context to a legal label is governed by the | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
782 specifications given in `reftex-derive-label-parameters'. |
18050 | 783 If RefTeX fails to derive a label, it will prompt the user. |
784 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
785 If PROMPT is t, the user will be prompted for a label string. The prompt will |
18050 | 786 already contain the prefix, and (if DERIVE is t) a default label derived from |
787 context. When PROMPT is nil, the default label will be inserted without | |
788 query. | |
789 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
790 So the combination of DERIVE and PROMPT controls label insertion. Here is a |
18050 | 791 table describing all four possibilities: |
792 | |
793 DERIVE PROMPT ACTION | |
794 ------------------------------------------------------------------------- | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
795 nil nil Insert simple label, like eq:22 or sec:13. No query. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
796 nil t Prompt for label. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
797 t nil Derive a label from context and insert without query. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
798 t t Derive a label from context and prompt for confirmation. |
18050 | 799 |
800 Each flag may be set to t, nil, or a string of label type letters | |
801 indicating the label types for which it should be true. | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
802 Thus, the combination may be set differently for each label type. The |
18050 | 803 default settings \"s\" and \"sft\" mean: Derive section labels from headings |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
804 (with confirmation). Prompt for figure and table labels. Use simple labels |
18050 | 805 without confirmation for everything else." |
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) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
810 (string :tag "selected label types" "")) |
18050 | 811 (choice :tag "Prompt for label string " |
812 :entry-format " %b %v" | |
813 (const :tag "always" t) | |
814 (const :tag "never" nil) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
815 (string :tag "selected label types" "")))) |
18050 | 816 |
817 (defcustom reftex-derive-label-parameters '(3 20 t 1 "-" ; continue | |
818 ("the" "on" "in" "off" "a" "for" "by" "of" "and" "is")) | |
819 "Parameters for converting a string into a label. | |
820 NWORDS Number of words to use. | |
821 MAXCHAR Maximum number of characters in a label string. | |
822 ILLEGAL nil: Throw away any words containing characters illegal in labels. | |
823 t: Throw away only the illegal characters, not the whole word. | |
824 ABBREV nil: Never abbreviate words. | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
825 t: Always abbreviate words (see `reftex-abbrev-parameters'). |
18050 | 826 not t and not nil: Abbreviate words if necessary to shorten |
827 label string below MAXCHAR. | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
828 SEPARATOR String separating different words in the label. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
829 IGNOREWORDS List of words which should not be part of labels." |
18050 | 830 :group 'reftex-making-and-inserting-labels |
831 :type '(list (integer :tag "Number of words " 3) | |
832 (integer :tag "Maximum label length " 20) | |
833 (choice :tag "Illegal characters in words" | |
834 (const :tag "throw away entire word" nil) | |
835 (const :tag "throw away single chars" t)) | |
836 (choice :tag "Abbreviate words " | |
837 (const :tag "never" nil) | |
838 (const :tag "always" t) | |
839 (const :tag "when label is too long" 1)) | |
840 (string :tag "Separator between words " "-") | |
841 (repeat :tag "Ignore words" | |
842 :entry-format " %i %d %v" | |
843 (string :tag "")))) | |
844 | |
845 (defcustom reftex-label-illegal-re "[\000-\040\177-\377\\\\#$%&~^_{}]" | |
846 "Regexp matching characters not legal in labels. | |
847 For historic reasons, this character class comes *with* the [] brackets." | |
848 :group 'reftex-making-and-inserting-labels | |
849 :type '(regexp :tag "Character class")) | |
850 | |
851 (defcustom reftex-abbrev-parameters '(4 2 "^saeiou" "aeiou") | |
852 "Parameters for abbreviation of words. | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
853 MIN-CHARS Minimum number of characters remaining after abbreviation. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
854 MIN-KILL Minimum number of characters to remove when abbreviating words. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
855 BEFORE Character class before abbrev point in word. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
856 AFTER Character class after abbrev point in word." |
18050 | 857 :group 'reftex-making-and-inserting-labels |
858 :type '(list | |
859 (integer :tag "Minimum chars per word" 4) | |
860 (integer :tag "Shorten by at least " 2) | |
861 (string :tag "cut before char class " "^saeiou") | |
862 (string :tag "cut after char class " "aeiou"))) | |
863 | |
864 ;; Label referencing | |
865 | |
866 (defgroup reftex-referencing-labels nil | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
867 "Options on how to reference labels." |
18050 | 868 :group 'reftex-label-support) |
869 | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
870 (defcustom reftex-label-menu-flags '(t t nil nil nil nil t) |
18050 | 871 "*List of flags governing the label menu makeup. |
872 The flags are: | |
873 | |
874 TABLE-OF-CONTENTS Show the labels embedded in a table of context. | |
875 SECTION-NUMBERS Include section numbers (like 4.1.3) in table of contents. | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
876 COUNTERS Show counters. This just numbers the labels in the menu. |
18050 | 877 NO-CONTEXT Non-nil means do NOT show the short context. |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
878 FOLLOW Follow full context in other window. |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
879 SHOW-COMMENTED Show labels from regions which are commented out. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
880 MATCH-IN-TOC Searches in label menu will also match in toc lines. |
18050 | 881 |
882 Each of these flags can be set to t or nil, or to a string of type letters | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
883 indicating the label types for which it should be true. These strings work |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
884 like character classes in regular expressions. Thus, setting one of the |
18050 | 885 flags to \"sf\" makes the flag true for section and figure labels, nil |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
886 for everything else. Setting it to \"^ft\" makes it the other way round. |
18050 | 887 |
888 Most options can also be switched from the label menu itself - so if you | |
889 decide here to not have a table of contents in the label menu, you can still | |
890 get one interactively during selection from the label menu." | |
891 :group 'reftex-referencing-labels | |
892 :type '(list | |
893 (choice :tag "Embed in table of contents " | |
894 (const :tag "on" t) (const :tag "off" nil) | |
895 (string :tag "Selected label types")) | |
896 (choice :tag "Show section numbers " | |
897 (const :tag "on" t) (const :tag "off" nil)) | |
898 (choice :tag "Show individual counters " | |
899 (const :tag "on" t) (const :tag "off" nil) | |
900 (string :tag "Selected label types")) | |
901 (choice :tag "Hide short context " | |
902 (const :tag "on" t) (const :tag "off" nil) | |
903 (string :tag "Selected label types")) | |
904 (choice :tag "Follow context in other window" | |
905 (const :tag "on" t) (const :tag "off" nil) | |
906 (string :tag "Selected label types")) | |
907 (choice :tag "Show commented labels " | |
908 (const :tag "on" t) (const :tag "off" nil) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
909 (string :tag "Selected label types")) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
910 (choice :tag "Searches match in toc lines " |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
911 (const :tag "on" t) (const :tag "off" nil) |
18050 | 912 (string :tag "Selected label types")))) |
913 | |
914 | |
915 (defcustom reftex-guess-label-type t | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
916 "*Non-nil means, `reftex-reference' will try to guess the label type. |
18050 | 917 To do that, RefTeX will look at the word before the cursor and compare it with |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
918 the words given in `reftex-label-alist'. When it finds a match, RefTeX will |
18050 | 919 immediately offer the correct label menu - otherwise it will prompt you for |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
920 a label type. If you set this variable to nil, RefTeX will always prompt." |
18050 | 921 :group 'reftex-referencing-labels |
922 :type '(boolean)) | |
923 | |
924 ;; BibteX citation configuration ---------------------------------------- | |
925 | |
926 (defgroup reftex-citation-support nil | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
927 "Support for referencing bibliographic data with BibTeX." |
18050 | 928 :group 'reftex) |
929 | |
930 (defcustom reftex-bibpath-environment-variables '("BIBINPUTS" "TEXBIB") | |
931 "*List of env vars which might contain the path to BibTeX database files." | |
932 :group 'reftex-citation-support | |
933 :set 'reftex-set-dirty | |
934 :type '(repeat (string :tag "Environment variable"))) | |
935 | |
936 (defcustom reftex-bibfile-ignore-list nil | |
937 "List of files in \\bibliography{..} RefTeX should *not* parse. | |
938 The file names have to be in the exact same form as in the bibliography | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
939 macro - i.e. without the `.bib' extension. |
18050 | 940 Intended for files which contain only `@string' macro definitions and the |
941 like, which are ignored by RefTeX anyway." | |
942 :group 'reftex-citation-support | |
943 :set 'reftex-set-dirty | |
944 :type '(repeat (string :tag "File name"))) | |
945 | |
946 (defcustom reftex-sort-bibtex-matches 'reverse-year | |
947 "*Sorting of the entries found in BibTeX databases by reftex-citation. | |
948 Possible values: | |
949 nil Do not sort entries. | |
950 'author Sort entries by author name. | |
951 'year Sort entries by increasing year. | |
952 'reverse-year Sort entries by decreasing year." | |
953 :group 'reftex-citation-support | |
954 :type '(choice (const :tag "not" nil) | |
955 (const :tag "by author" author) | |
956 (const :tag "by year" year) | |
957 (const :tag "by year, reversed" reverse-year))) | |
958 | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
959 (defcustom reftex-cite-format 'default |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
960 "The format of citations to be inserted into the buffer. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
961 It can be a string or an alist. In the simplest case this is just |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
962 the string \"\\cite{%l}\", which is also the default. See the |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
963 definition of `reftex-cite-format-builtin' for more complex examples. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
964 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
965 If `reftex-cite-format' is a string, it will be used as the format. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
966 In the format, the following percent escapes will be expanded. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
967 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
968 %l The BibTeX label of the citation. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
969 %a List of author names, see also `reftex-cite-punctuation. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
970 %2a Like %a, but abbreviate more than 2 authors like Jones et al. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
971 %A First author name only. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
972 %e Works like %a, but on list of editor names. (%2e and %E work a well) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
973 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
974 It is also possible to access all other BibTeX database fields: |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
975 %b booktitle %c chapter %d edition %h howpublished |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
976 %i institution %j journal %k key %m month |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
977 %n number %o organization %p pages %P first page |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
978 %r address %s school %u publisher %t title |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
979 %v volume %y year |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
980 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
981 Usually, only %l is needed. Try, however, (setq reftex-comment-citations t). |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
982 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
983 If `reftex-cite-format' is an alist of characters and strings, the user |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
984 will be prompted for a character to select one of the possible format |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
985 strings. |
18050 | 986 In order to configure this variable, you can either set |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
987 `reftex-cite-format' directly yourself or set it to the SYMBOL of one of |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
988 the predefined styles (see `reftex-cite-format-builtin'). E.g.: |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
989 (setq reftex-cite-format 'harvard)" |
18050 | 990 :group 'reftex-citation-support |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
991 :type |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
992 '(choice :format "%{%t%}: \n%[Value Menu%] %v" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
993 (radio :tag "Symbolic Builtins" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
994 :indent 4 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
995 :value default |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
996 ;; Update here with: update-builtin-cite |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
997 (const :tag "default: Default macro \\cite{%l}" default) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
998 (const :tag "harvard: P. William's and T. Schnier's Harvard package" harvard) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
999 (const :tag "natbib: Patrick W. Daly's Natbib package" natbib) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1000 (const :tag "astron: S. Hogeveen's Astron package" astron) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1001 (const :tag "author-year: Do-it-yourself Author year citation" author-year) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1002 (const :tag "locally: Put full info in parenthesis" locally)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1003 (string :tag "format string" "\\cite{%l}") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1004 (repeat :tag "key-ed format strings" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1005 :value ((?\r . "\\cite{%l}") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1006 (?t . "\\cite{%l}") (?p . "\\cite{%l}")) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1007 (cons (character :tag "Key character" ?\r) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1008 (string :tag "Format string" ""))))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1009 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1010 (defcustom reftex-comment-citations nil |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1011 "Non-nil means add a comment for each citation describing the full entry. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1012 The comment is formatted according to `reftex-cite-comment-format'." |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1013 :group 'reftex-citation-support |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1014 :type '(boolean)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1015 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1016 (defcustom reftex-cite-comment-format ; continue |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1017 "%% %2a %y, %j %v, %P, %e: %b, %u, %s %<\n" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1018 "Citation format used for commented citations. Must NOT contain %l." |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1019 :group 'reftex-citation-support |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1020 :type '(string)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1021 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1022 (defcustom reftex-cite-punctuation '(", " " \\& " " {\\it et al.}") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1023 "Punctuation for formatting of name lists in citations. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1024 This is a list of 3 strings. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1025 1. normal names separator, like \", \" in Jones, Brown and Miller |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1026 2. final names separator, like \" and \" in Jones, Brown and Miller |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1027 3. The \"et al\" string, like \" {...}\" in Jones {\\it et al.}" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1028 :group 'reftex-citation-support |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1029 :type '(list |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1030 (string :tag "Separator for names ") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1031 (string :tag "Separator for last name in list") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1032 (string :tag "string used as et al. "))) |
18050 | 1033 |
1034 ;; Table of contents configuration -------------------------------------- | |
1035 | |
1036 (defgroup reftex-table-of-contents-browser nil | |
1037 "A multifile table of contents browser." | |
1038 :group 'reftex) | |
1039 | |
1040 (defcustom reftex-toc-follow-mode nil | |
1041 "Non-nil means, point in *toc* buffer will cause other window to follow. | |
1042 The other window will show the corresponding part of the document. | |
1043 This flag can be toggled from within the *toc* buffer with the `f' key." | |
1044 :group 'reftex-table-of-contents-browser | |
1045 :type '(boolean)) | |
1046 | |
1047 ;; Miscellaneous configurations ----------------------------------------- | |
1048 | |
1049 (defgroup reftex-miscellaneous-configurations nil | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1050 "Collection of further configurations." |
18050 | 1051 :group 'reftex) |
1052 | |
1053 (defcustom reftex-extra-bindings nil | |
1054 "Non-nil means, make additional key bindings on startup. | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1055 These extra bindings are located in the users `C-c letter' map." |
18050 | 1056 :group 'reftex-miscellaneous-configurations |
1057 :type '(boolean)) | |
1058 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1059 (defcustom reftex-plug-into-AUCTeX nil |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1060 "Plug-in flags for AUCTeX interface. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1061 This variable is a list of 4 boolean flags. When a flag is non-nil, it |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1062 means: |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1063 |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1064 Flag 1: use `reftex-label' as `LaTeX-label-function'. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1065 Flag 2: use `reftex-arg-label' as `TeX-arg-label' |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1066 Flag 3: use `reftex-arg-ref' as `TeX-arg-ref' |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1067 Flag 4: use `reftex-arg-cite' as `TeX-arg-cite' |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1068 |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1069 You may also set the variable itself to t or nil in order to turn all |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1070 plug-ins on or off, respectively. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1071 \\<LaTeX-mode-map>`LaTeX-label-function' is the function used for label insertion when you |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1072 enter a new environment in AUCTeX with \\[LaTeX-environment]. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1073 The `TeX-arg-label' etc. functions are for entering macro arguments during |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1074 macro insertion with \\[TeX-insert-macro]. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1075 See the AUCTeX documentation for more information. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1076 RefTeX uses `fset' to take over the function calls. Changing the variable |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1077 may require a restart of Emacs in order to become effective." |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1078 :group 'reftex-miscellaneous-configurations |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1079 :type '(choice (const :tag "No plug-ins" nil) |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1080 (const :tag "All possible plug-ins" t) |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1081 (list |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1082 :tag "Individual choice" |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1083 :value (nil nil nil nil) |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1084 (boolean :tag "Use reftex-label as LaTeX-label-function") |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1085 (boolean :tag "Use reftex-arg-label as TeX-arg-label ") |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1086 (boolean :tag "Use reftex-arg-ref as TeX-arg-ref ") |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1087 (boolean :tag "Use reftex-arg-cite as TeX-arg-cite ") |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1088 ))) |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1089 |
18050 | 1090 (defcustom reftex-use-fonts t |
1091 "*Non-nil means, use fonts in label menu and on-the-fly help. | |
1092 Font-lock must be loaded as well to actually get fontified display." | |
1093 :group 'reftex-miscellaneous-configurations | |
1094 :type '(boolean)) | |
1095 | |
1096 (defcustom reftex-keep-temporary-buffers t | |
1097 "*Non-nil means, keep any TeX and BibTeX files loaded for lookup. | |
1098 Nil means, kill it immediately after use unless it was already an existing | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1099 buffer before the lookup happened. It is faster to keep the buffers, but can |
18050 | 1100 use a lot of memory, depending on the size of your database and document." |
1101 :group 'reftex-miscellaneous-configurations | |
1102 :type '(boolean)) | |
1103 | |
1104 (defcustom reftex-auto-show-entry t | |
1105 "*Non-nil means, showing context in another window may unhide a section. | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1106 This is important when using outline-minor-mode. If the context to be shown |
18050 | 1107 is in a hidden section, RefTeX will issue a \"show-entry\" command in order |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1108 to show it. This is not reversed when the label is selected - so the section |
18050 | 1109 remains shown after command completion." |
1110 :group 'reftex-miscellaneous-configurations | |
1111 :type '(boolean)) | |
1112 | |
1113 ;;; End of Configuration Section ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
1114 | |
1115 ;;;=========================================================================== | |
1116 ;;; | |
1117 ;;; Define the formal stuff for a minor mode named RefTeX. | |
1118 ;;; | |
1119 | |
1120 (defvar reftex-mode nil | |
1121 "Determines if RefTeX minor mode is active.") | |
1122 (make-variable-buffer-local 'reftex-mode) | |
1123 | |
1124 (defvar reftex-mode-map (make-sparse-keymap) | |
1125 "Keymap for RefTeX minor mode.") | |
1126 | |
1127 (defvar reftex-mode-menu nil) | |
1128 | |
1129 ;;;###autoload | |
1130 (defun turn-on-reftex () | |
1131 "Turn on RefTeX minor mode." | |
1132 (reftex-mode t)) | |
1133 | |
1134 ;;;###autoload | |
1135 (defun reftex-mode (&optional arg) | |
18123 | 1136 "Minor mode with distinct support for \\label, \\ref and \\cite in LaTeX. |
18050 | 1137 |
1138 Labels can be created with `\\[reftex-label]' and referenced with `\\[reftex-reference]'. | |
1139 When referencing, you get a menu with all labels of a given type and | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1140 context of the label definition. The selected label is inserted as a |
18123 | 1141 \\ref macro. |
18050 | 1142 |
1143 Citations can be made with `\\[reftex-citation]' which will use a regular expression | |
1144 to pull out a *formatted* list of articles from your BibTeX | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1145 database. The selected citation is inserted as a \\cite macro. |
18050 | 1146 |
1147 A Table of Contents of the entire (multifile) document with browsing | |
1148 capabilities is available with `\\[reftex-toc]'. | |
1149 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1150 Most command have help available on the fly. This help is accessed by |
18050 | 1151 pressing `?' to any prompt mentioning this feature. |
1152 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1153 Extensive documentation about reftex is in the file header of `reftex.el'. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1154 |
18050 | 1155 \\{reftex-mode-map} |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1156 Under X, these functions will also be available in a menu on the menu bar. |
18050 | 1157 |
1158 ------------------------------------------------------------------------------" | |
1159 | |
1160 (interactive "P") | |
1161 (setq reftex-mode (not (or (and (null arg) reftex-mode) | |
1162 (<= (prefix-numeric-value arg) 0)))) | |
1163 | |
1164 ; Add or remove the menu, and run the hook | |
1165 (if reftex-mode | |
1166 (progn | |
1167 (easy-menu-add reftex-mode-menu) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1168 (reftex-plug-into-AUCTeX) |
18050 | 1169 (run-hooks 'reftex-mode-hook)) |
1170 (easy-menu-remove reftex-mode-menu))) | |
1171 | |
1172 (or (assoc 'reftex-mode minor-mode-alist) | |
1173 (setq minor-mode-alist | |
1174 (cons '(reftex-mode " Ref") minor-mode-alist))) | |
1175 | |
1176 (or (assoc 'reftex-mode minor-mode-map-alist) | |
1177 (setq minor-mode-map-alist | |
1178 (cons (cons 'reftex-mode reftex-mode-map) | |
1179 minor-mode-map-alist))) | |
1180 | |
1181 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1182 |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1183 |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1184 |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1185 |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1186 |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1187 |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1188 |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1189 |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1190 ;;; =========================================================================== |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1191 ;;; |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1192 ;;; Silence warnings about variables in other packages. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1193 (defvar TeX-master) |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1194 (defvar LaTeX-label-function) |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1195 (defvar tex-main-file) |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1196 (defvar outline-minor-mode) |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1197 |
18050 | 1198 ;;; =========================================================================== |
1199 ;;; | |
1200 ;;; Interfaces for other packages | |
1201 ;;; ----------------------------- | |
1202 ;;; | |
1203 ;;; AUCTeX | |
1204 ;;; ------ | |
1205 | |
1206 (defun reftex-arg-label (optional &optional prompt definition) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1207 "Use `reftex-label' to create label. Insert it with `TeX-argument-insert'. |
18050 | 1208 This function is intended for AUCTeX macro support." |
1209 (let ((label (reftex-label nil t))) | |
1210 (if (and definition (not (string-equal "" label))) | |
1211 (LaTeX-add-labels label)) | |
1212 (TeX-argument-insert label optional optional))) | |
1213 | |
1214 (defun reftex-arg-ref (optional &optional prompt definition) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1215 "Use `reftex-reference' to select label. Insert with `TeX-argument-insert'. |
18050 | 1216 This function is intended for AUCTeX macro support." |
1217 (let ((label (reftex-reference nil t))) | |
1218 (if (and definition (not (string-equal "" label))) | |
1219 (LaTeX-add-labels label)) | |
1220 (TeX-argument-insert label optional optional))) | |
1221 | |
1222 (defun reftex-arg-cite (optional &optional prompt definition) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1223 "Use reftex-citation to select a key. Insert with `TeX-argument-insert'. |
18050 | 1224 This function is intended for AUCTeX macro support." |
1225 (let ((key (reftex-citation nil t))) | |
1226 (TeX-argument-insert (or key "") optional optional))) | |
1227 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1228 (defun reftex-plug-into-AUCTeX () |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1229 ;; Replace AucTeX functions with RefTeX functions. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1230 ;; Which functions are replaced is controlled by the variable |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1231 ;; `reftex-plug-into-AUCTeX'. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1232 (let ((flags |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1233 (cond ((eq reftex-plug-into-AUCTeX t) '(t t t t)) |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1234 ((eq reftex-plug-into-AUCTeX nil) '(nil nil nil nil)) |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1235 (t reftex-plug-into-AUCTeX)))) |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1236 |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1237 (and (nth 0 flags) |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1238 (boundp 'LaTeX-label-function) |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1239 (setq LaTeX-label-function 'reftex-label)) |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1240 |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1241 (and (nth 1 flags) |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1242 (fboundp 'TeX-arg-label) |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1243 (fset 'TeX-arg-label 'reftex-arg-label)) |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1244 |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1245 (and (nth 2 flags) |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1246 (fboundp 'TeX-arg-ref) |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1247 (fset 'TeX-arg-ref 'reftex-arg-ref)) |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1248 |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1249 (and (nth 3 flags) |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1250 (fboundp 'TeX-arg-cite) |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1251 (fset 'TeX-arg-cite 'reftex-arg-cite)))) |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1252 |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1253 |
18050 | 1254 (defvar reftex-label-alist-external-add-ons nil |
1255 "List of label alist entries added with reftex-add-to-label-alist.") | |
1256 | |
1257 ;;;###autoload | |
1258 (defun reftex-add-to-label-alist (entry-list) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1259 "Add label environment descriptions to `reftex-label-alist-external-add-ons'. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1260 The format of ENTRY-LIST is exactly like `reftex-label-alist'. See there |
18050 | 1261 for details. |
1262 This function makes it possible to support RefTeX from AUCTeX style files. | |
1263 The entries in ENTRY-LIST will be processed after the user settings in | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1264 `reftex-label-alist', and before the defaults (specified in |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1265 `reftex-default-label-alist-entries'). Any changes made to |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1266 `reftex-label-alist-external-add-ons' will raise a flag to the effect that a |
18050 | 1267 mode reset is done on the next occasion." |
1268 (let (entry) | |
1269 (while entry-list | |
1270 (setq entry (car entry-list) | |
1271 entry-list (cdr entry-list)) | |
1272 (if (not (member entry reftex-label-alist-external-add-ons)) | |
1273 (setq reftex-tables-dirty t | |
1274 reftex-label-alist-external-add-ons | |
1275 (cons entry reftex-label-alist-external-add-ons)))))) | |
1276 | |
1277 ;;; =========================================================================== | |
1278 ;;; | |
1279 ;;; Multifile support | |
1280 ;;; | |
1281 ;;; Technical notes: Multifile works as follows: We keep just one list | |
1282 ;;; of labels for each master file - this can save a lot of memory. | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1283 ;;; `reftex-master-index-list' is an alist which connects the true file name |
18050 | 1284 ;;; of each master file with the symbols holding the information on that |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1285 ;;; document. Each buffer has local variables which point to these symbols. |
18050 | 1286 |
1287 ;; List of variables which handle the multifile stuff. | |
1288 ;; This list is used to tie, untie, and reset these symbols. | |
1289 (defconst reftex-multifile-symbols | |
1290 '(reftex-label-numbers-symbol reftex-list-of-labels-symbol | |
1291 reftex-bibfile-list-symbol)) | |
1292 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1293 ;; Alist connecting master file names with the corresponding lisp symbols. |
18050 | 1294 (defvar reftex-master-index-list nil) |
1295 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1296 ;; Last index used for a master file. |
18050 | 1297 (defvar reftex-multifile-index 0) |
1298 | |
1299 ;; Alist connecting a master file with all included files. | |
1300 (defvar reftex-master-include-list nil) | |
1301 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1302 ;; Variable holding the symbol with current value of label postfix. |
18050 | 1303 (defvar reftex-label-numbers-symbol nil ) |
1304 (make-variable-buffer-local 'reftex-label-numbers-symbol) | |
1305 | |
1306 ;; Variable holding the symbol with the label list of the document. | |
1307 ;; Each element of the label list is again a list with the following elements: | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1308 ;; 0: One character label type indicator. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1309 ;; 1: Short context to put into label menu. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1310 ;; 2: The label. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1311 ;; 3: The name of the file where the label is defined. |
18050 | 1312 (defvar reftex-list-of-labels-symbol nil) |
1313 (make-variable-buffer-local 'reftex-list-of-labels-symbol) | |
1314 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1315 ;; Variable holding the symbol with a list of library files for this document. |
18050 | 1316 (defvar reftex-bibfile-list-symbol nil) |
1317 (make-variable-buffer-local 'reftex-bibfile-list-symbol) | |
1318 | |
1319 (defun reftex-next-multifile-index () | |
1320 ;; Return the next free index for multifile symbols. | |
1321 (setq reftex-multifile-index (1+ reftex-multifile-index))) | |
1322 | |
1323 (defun reftex-tie-multifile-symbols () | |
1324 ;; Tie the buffer-local symbols to globals connected with the master file. | |
1325 ;; If the symbols for the current master file do not exist, they are created. | |
1326 | |
1327 (let* ((master (file-truename (reftex-TeX-master-file))) | |
1328 (index (assoc master reftex-master-index-list)) | |
1329 (symlist reftex-multifile-symbols) | |
1330 (symbol nil) | |
1331 (symname nil) | |
1332 (newflag nil)) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1333 ;; Find the correct index. |
18050 | 1334 (if index |
1335 ;; symbols do exist | |
1336 (setq index (cdr index)) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1337 ;; Get a new index and add info to the alist. |
18050 | 1338 (setq index (reftex-next-multifile-index) |
1339 reftex-master-index-list (cons | |
1340 (cons master index) | |
1341 reftex-master-index-list) | |
1342 newflag t)) | |
1343 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1344 ;; Get/create symbols and tie them. |
18050 | 1345 (while symlist |
1346 (setq symbol (car symlist) | |
1347 symlist (cdr symlist) | |
1348 symname (symbol-name symbol)) | |
1349 (set symbol (intern (concat symname "-" (int-to-string index)))) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1350 ;; Initialize if new symbols. |
18050 | 1351 (if newflag (set (symbol-value symbol) nil))) |
1352 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1353 ;; Return t if the symbols did already exist, nil when we've made them. |
18050 | 1354 (not newflag))) |
1355 | |
1356 (defun reftex-untie-multifile-symbols () | |
1357 ;; Remove ties from multifile symbols, so that next use makes new ones. | |
1358 (let ((symlist reftex-multifile-symbols) | |
1359 (symbol nil)) | |
1360 (while symlist | |
1361 (setq symbol (car symlist) | |
1362 symlist (cdr symlist)) | |
1363 (set symbol nil)))) | |
1364 | |
1365 (defun reftex-TeX-master-file () | |
1366 ;; Return the name of the master file associated with the current buffer. | |
1367 ;; When AUCTeX is loaded, we will use it's more sophisticated method. | |
18219
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
1368 ;; We also support the default TeX and LaTeX modes by checking for a |
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
1369 ;; variable tex-main-file. |
18050 | 1370 |
1371 (let | |
1372 ((master | |
1373 (cond | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1374 ((fboundp 'TeX-master-file) ; AUCTeX is loaded. Use its mechanism. |
18050 | 1375 (TeX-master-file t)) |
1376 ((boundp 'TeX-master) ; The variable is defined - lets use it. | |
1377 (cond | |
1378 ((eq TeX-master t) | |
1379 (buffer-file-name)) | |
1380 ((eq TeX-master 'shared) | |
1381 (setq TeX-master (read-file-name "Master file: " | |
1382 nil nil t nil))) | |
1383 (TeX-master) | |
1384 (t | |
1385 (setq TeX-master (read-file-name "Master file: " | |
1386 nil nil t nil))))) | |
1387 ((boundp 'tex-main-file) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1388 ;; This is the variable from the default TeX modes. |
18050 | 1389 (cond |
1390 ((stringp tex-main-file) | |
1391 ;; ok, this must be it | |
1392 tex-main-file) | |
1393 (t | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1394 ;; In this case, the buffer is its own master. |
18050 | 1395 (buffer-file-name)))) |
1396 (t | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1397 ;; Know nothing about master file. Assume this is a master file. |
18050 | 1398 (buffer-file-name))))) |
1399 (cond | |
1400 ((null master) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1401 (error "Need a filename for this buffer. Please save it first.")) |
18050 | 1402 ((or (file-exists-p master) |
1403 (reftex-get-buffer-visiting master)) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1404 ;; We either see the file, or have a buffer on it. OK. |
18050 | 1405 ) |
1406 ((or (file-exists-p (concat master ".tex")) | |
1407 (reftex-get-buffer-visiting (concat master ".tex"))) | |
1408 ;; Ahh, an extra .tex was missing... | |
1409 (setq master (concat master ".tex"))) | |
1410 (t | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1411 ;; Something is wrong here. Throw an exception. |
18050 | 1412 (error "No such master file %s" master))) |
1413 (expand-file-name master))) | |
1414 | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1415 (defun reftex-make-master-buffer (master-file) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1416 ;; Make a master buffer which contains the MASTER-FILE and all includes. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1417 ;; This is to prepare a buffer containing the entire document in correct |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1418 ;; sequence for parsing. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1419 ;; After making the buffer, it runs reftex-make-master-buffer-hook. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1420 ;; The function returns the number of input/include files not found. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1421 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1422 (let ((not-found 0) file file1 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1423 file-list dir-list tmp |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1424 (this-syntax-table (syntax-table)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1425 (format-alist nil) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1426 (default-major-mode 'fundamental-mode) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1427 (after-insert-file-functions nil)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1428 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1429 ;; Set up the buffer with correct syntax table for parsing a tex buffer. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1430 ;; We do not use the mode because that may involve heavy stuff |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1431 ;; like font-lock etc. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1432 (switch-to-buffer "*RefTeX Master*") |
18050 | 1433 (erase-buffer) |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1434 (set-syntax-table this-syntax-table) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1435 |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1436 ;; First insert the master file. |
18050 | 1437 (if (not (file-exists-p master-file)) |
1438 (error "No such master file: %s" master-file)) | |
1439 (reftex-insert-buffer-or-file master-file) | |
1440 (subst-char-in-region (point-min) (point-max) ?\r ?\n t) | |
1441 (setq file-list (cons master-file file-list)) | |
1442 (goto-char 1) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1443 |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1444 ;; Remember from which file these lines came. |
18050 | 1445 (put-text-property (point-min) (point-max) 'file |
1446 (expand-file-name master-file)) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1447 |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1448 ;; Make the default directory that of the master file. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1449 ;; All input and include stuff works relative to that directory. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1450 (cd (file-name-directory (expand-file-name master-file))) |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1451 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1452 ;; Create the list of directories from the TEXINPUTS environment variable |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1453 (setq dir-list (cons default-directory |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1454 (reftex-split (concat path-separator "+") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1455 (or (getenv "TEXINPUTS") "")))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1456 |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1457 ;; Now find recursively all include/input statements and expand them. |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1458 (while |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1459 (re-search-forward |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1460 "^[ \t]*\\\\\\(include\\|input\\)[{ \t]+\\([^} \t\n\r]+\\)[} \t\n\r]" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1461 nil t) |
18050 | 1462 (setq file (reftex-no-props (match-string 2))) |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1463 (if (not (and (> (length file) 4) |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1464 (string= (substring file -4) ".tex"))) |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1465 (setq file (concat file ".tex"))) |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1466 (setq file1 file) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1467 (if (setq file (car (reftex-find-files-on-path (list file) dir-list))) |
18050 | 1468 (progn |
1469 (replace-match | |
1470 (format "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% START OF %s FILE: %s\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% END OF %s FILE: %s\n" | |
1471 (match-string 1) file | |
1472 (match-string 1) file)) | |
1473 (beginning-of-line 0) | |
1474 (narrow-to-region (point) (point)) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1475 ;; Insert the file. |
18050 | 1476 (reftex-insert-buffer-or-file file) |
1477 (subst-char-in-region (point-min) (point-max) ?\r ?\n t) | |
1478 (setq file-list (cons (expand-file-name file) file-list)) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1479 ;; Remember from which file these lines came. |
18050 | 1480 (put-text-property (point-min) (point-max) |
1481 'file (expand-file-name file)) | |
1482 (goto-char (point-min)) | |
1483 (widen)) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1484 (message "Input/include file %s not found. Ignored. Continuing..." |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1485 file1) |
18050 | 1486 (setq not-found (1+ not-found)))) |
1487 (setq file-list (nreverse file-list)) | |
1488 (while (setq tmp (assoc (car file-list) reftex-master-include-list)) | |
1489 (setq reftex-master-include-list (delq tmp reftex-master-include-list))) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1490 (setq reftex-master-include-list |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1491 (cons file-list reftex-master-include-list)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1492 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1493 ;; Run the hook |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1494 (run-hooks 'reftex-make-master-buffer-hook) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1495 |
18050 | 1496 not-found)) |
1497 | |
1498 (defun reftex-insert-buffer-or-file (file) | |
1499 "If there is a buffer associated with FILE, insert it - otherwise the FILE." | |
1500 (let ((buffer (reftex-get-buffer-visiting file))) | |
1501 (if buffer | |
1502 (let (beg end beg1 end1) | |
1503 (save-excursion | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1504 ;; Make sure we get the whole buffer. |
18050 | 1505 (set-buffer buffer) |
1506 (setq beg (point-min) end (point-max)) | |
1507 (widen) | |
1508 (setq beg1 (point-min) end1 (point-max))) | |
1509 (insert-buffer-substring buffer beg1 end1) | |
1510 (save-excursion | |
1511 (set-buffer buffer) | |
1512 (narrow-to-region beg end))) | |
1513 (insert-file-contents file)))) | |
1514 | |
1515 | |
1516 (defun reftex-parse-document (&optional buffer) | |
1517 "Rescan the document." | |
1518 (interactive) | |
1519 (save-window-excursion | |
1520 (save-excursion | |
1521 (if buffer | |
1522 (if (not (bufferp buffer)) | |
1523 (error "No such buffer %s" (buffer-name buffer)) | |
1524 (set-buffer buffer))) | |
1525 (reftex-access-scan-info t)))) | |
1526 | |
1527 (defun reftex-access-scan-info (&optional rescan) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1528 ;; Access the scanning info. When the multifile symbols are not yet tied, |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1529 ;; tie them. When they are have to be created, do a buffer scan to |
18050 | 1530 ;; fill them. |
1531 | |
1532 ;; If RESCAN is non-nil, enforce document scanning | |
1533 | |
1534 (catch 'exit | |
1535 (let ((rescan (or (equal rescan t) (equal rescan '(4))))) | |
1536 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1537 ;; Reset the mode if we had changes from style hooks. |
18050 | 1538 (and reftex-tables-dirty |
1539 (reftex-reset-mode)) | |
1540 | |
1541 (if (eq reftex-list-of-labels-symbol nil) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1542 ;; Symbols are not yet tied: Tie them and see if they are set. |
18050 | 1543 (reftex-tie-multifile-symbols)) |
1544 | |
1545 (if (and (symbol-value reftex-list-of-labels-symbol) | |
1546 (not rescan)) | |
1547 ;; Lists do already exist and we don't need to rescan. | |
1548 ;; Return from here. | |
1549 (throw 'exit t)) | |
1550 | |
1551 ;; We need to rescan | |
1552 ;; ================= | |
1553 | |
1554 (unwind-protect | |
1555 (save-window-excursion | |
1556 (save-excursion | |
1557 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1558 ;; Do the scanning. |
18050 | 1559 |
1560 (let ((label-list-symbol reftex-list-of-labels-symbol) | |
1561 (label-numbers-symbol reftex-label-numbers-symbol) | |
1562 (bibfile-list-symbol reftex-bibfile-list-symbol)) | |
1563 | |
1564 (message "Creating master buffer...") | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1565 (reftex-make-master-buffer (reftex-TeX-master-file)) |
18050 | 1566 |
1567 (message "Scanning document...") | |
1568 | |
1569 (reftex-scan-buffer-for-labels | |
1570 label-numbers-symbol label-list-symbol) | |
1571 | |
1572 (reftex-scan-buffer-for-bibliography-statement | |
1573 bibfile-list-symbol) | |
1574 | |
1575 (message "Scanning document... done")))) | |
1576 | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1577 (if (get-buffer "*RefTeX Master*") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1578 (kill-buffer "*RefTeX Master*")))))) |
18050 | 1579 |
1580 (defun reftex-create-tags-file () | |
1581 "Create TAGS file by running `etags' on the current document. | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1582 The TAGS file is also immediately visited with `visit-tags-table'." |
18050 | 1583 (interactive) |
1584 (reftex-access-scan-info current-prefix-arg) | |
1585 (let* ((master (reftex-TeX-master-file)) | |
1586 (files (assoc master reftex-master-include-list)) | |
1587 (cmd (format "etags %s" (mapconcat 'identity files " ")))) | |
1588 (save-excursion | |
1589 (set-buffer (reftex-get-buffer-visiting master)) | |
1590 (message "Running etags to create TAGS file...") | |
1591 (shell-command cmd) | |
1592 (visit-tags-table "TAGS")))) | |
1593 | |
1594 ;; History of grep commands. | |
1595 (defvar reftex-grep-history nil) | |
1596 (defvar reftex-grep-command "grep -n " | |
1597 "Last grep command used in \\[reftex-grep-document]; default for next grep.") | |
1598 | |
1599 (defun reftex-grep-document (grep-cmd) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1600 "Run grep query through all files related to this document. |
18050 | 1601 With prefix arg, force to rescan document. |
1602 This works also without an active TAGS table." | |
1603 | |
1604 (interactive | |
1605 (list (read-from-minibuffer "Run grep on document (like this): " | |
1606 reftex-grep-command nil nil | |
1607 'reftex-grep-history))) | |
1608 (reftex-access-scan-info current-prefix-arg) | |
1609 (let* ((master (reftex-TeX-master-file)) | |
1610 (default-directory (file-name-directory master)) | |
1611 (re (format "\\`%s\\(.*\\)" (regexp-quote | |
1612 (expand-file-name default-directory)))) | |
1613 (files (assoc master reftex-master-include-list)) | |
1614 (cmd (format | |
1615 "%s %s" grep-cmd | |
1616 (mapconcat (function (lambda (x) | |
1617 (if (string-match re x) | |
1618 (match-string 1 x) | |
1619 x))) | |
1620 files " ")))) | |
1621 (grep cmd))) | |
1622 | |
1623 (defun reftex-search-document (&optional regexp) | |
1624 "Regexp search through all files of the current TeX document. | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1625 Starts always in the master file. Stops when a match is found. |
18050 | 1626 To continue searching for next match, use command \\[tags-loop-continue]. |
1627 This works also without an active TAGS table." | |
1628 (interactive) | |
1629 (let ((default (reftex-this-word))) | |
1630 (if (not regexp) | |
1631 (setq regexp (read-string (format "Search regexp in document [%s]: " | |
1632 default)))) | |
1633 (if (string= regexp "") (setq regexp (regexp-quote default))) | |
1634 | |
1635 (reftex-access-scan-info current-prefix-arg) | |
1636 (tags-search regexp (list 'assoc (reftex-TeX-master-file) | |
1637 'reftex-master-include-list)))) | |
1638 | |
1639 (defun reftex-query-replace-document (&optional from to delimited) | |
1640 "Run a query-replace-regexp of FROM with TO over the entire TeX document. | |
1641 Third arg DELIMITED (prefix arg) means replace only word-delimited matches. | |
1642 If you exit (\\[keyboard-quit] or ESC), you can resume the query replace | |
1643 with the command \\[tags-loop-continue]. | |
1644 This works also without an active TAGS table." | |
1645 (interactive) | |
1646 (let ((default (reftex-this-word))) | |
1647 (if (not from) | |
1648 (progn | |
1649 (setq from (read-string (format "Replace regexp in document [%s]: " | |
1650 default))) | |
1651 (if (string= from "") (setq from (regexp-quote default))))) | |
1652 (if (not to) | |
1653 (setq to (read-string (format "Replace regexp %s with: " from)))) | |
1654 (reftex-access-scan-info current-prefix-arg) | |
1655 (tags-query-replace from to (or delimited current-prefix-arg) | |
1656 (list 'assoc (reftex-TeX-master-file) | |
1657 'reftex-master-include-list)))) | |
1658 | |
1659 (defun reftex-change-label (&optional from to) | |
18123 | 1660 "Query replace FROM with TO in all \\label and \\ref commands. |
18050 | 1661 Works on the entire multifile document. |
1662 If you exit (\\[keyboard-quit] or ESC), you can resume the query replace | |
1663 with the command \\[tags-loop-continue]. | |
1664 This works also without an active TAGS table." | |
1665 (interactive) | |
1666 (let ((default (reftex-this-word "-a-zA-Z0-9_*.:"))) | |
1667 (if (not from) | |
1668 (setq from (read-string (format "Replace label globally [%s]: " | |
1669 default)))) | |
1670 (if (string= from "") (setq from default)) | |
1671 (if (not to) | |
1672 (setq to (read-string (format "Replace label %s with: " | |
1673 from)))) | |
1674 (reftex-query-replace-document | |
1675 (concat "\\\\\\(label\\|[a-z]*ref\\){" (regexp-quote from) "}") | |
1676 (format "\\\\\\1{%s}" to)))) | |
1677 | |
1678 (defun reftex-this-word (&optional class) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1679 ;; Grab the word around point. |
18050 | 1680 (setq class (or class "-a-zA-Z0-9:_/.*;|")) |
1681 (save-excursion | |
1682 (buffer-substring-no-properties | |
1683 (progn (skip-chars-backward class) (point)) | |
1684 (progn (skip-chars-forward class) (point))))) | |
1685 | |
1686 ;;; =========================================================================== | |
1687 ;;; | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1688 ;;; Functions to create and reference automatic labels. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1689 |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1690 ;; The following constants are derived from `reftex-label-alist'. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1691 |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1692 ;; Prompt used for label type querys directed to the user. |
18050 | 1693 (defconst reftex-type-query-prompt nil) |
1694 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1695 ;; Help string for label type querys. |
18050 | 1696 (defconst reftex-type-query-help nil) |
1697 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1698 ;; Alist relating label type to reference format. |
18050 | 1699 (defconst reftex-typekey-to-format-alist nil) |
1700 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1701 ;; Alist relating label type to label affix. |
18050 | 1702 (defconst reftex-typekey-to-prefix-alist nil) |
1703 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1704 ;; Alist relating environments or macros to label type and context regexp. |
18050 | 1705 (defconst reftex-env-or-mac-alist nil) |
1706 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1707 ;; List of macros carrying a label. |
18050 | 1708 (defconst reftex-label-mac-list nil) |
1709 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1710 ;; List of environments carrying a label. |
18050 | 1711 (defconst reftex-label-env-list nil) |
1712 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1713 ;; List of all typekey letters in use. |
18050 | 1714 (defconst reftex-typekey-list nil) |
1715 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1716 ;; Alist relating magic words to a label type. |
18050 | 1717 (defconst reftex-words-to-typekey-alist nil) |
1718 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1719 ;; The last list-of-labels entry used in a reference. |
18050 | 1720 (defvar reftex-last-used-reference (list nil nil nil nil)) |
1721 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1722 ;; The regular expression used to abbreviate words. |
18050 | 1723 (defconst reftex-abbrev-regexp |
1724 (concat | |
1725 "^\\(" | |
1726 (make-string (nth 0 reftex-abbrev-parameters) ?.) | |
1727 "[" (nth 2 reftex-abbrev-parameters) "]*" | |
1728 "\\)" | |
1729 "[" (nth 3 reftex-abbrev-parameters) "]" | |
1730 (make-string (1- (nth 1 reftex-abbrev-parameters)) ?.))) | |
1731 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1732 ;; Global variables used for communication between functions. |
18050 | 1733 (defvar reftex-default-context-position nil) |
1734 (defvar reftex-location-start nil) | |
1735 (defvar reftex-call-back-to-this-buffer nil) | |
1736 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1737 ;; List of buffers created temporarily for lookup, which should be killed. |
18050 | 1738 (defvar reftex-buffers-to-kill nil) |
1739 | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1740 ;; Regexp to find section statements. Computed from reftex-section-levels. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1741 (defvar reftex-section-regexp nil) |
18050 | 1742 |
1743 ;; LaTeX section commands and level numbers | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1744 (defcustom reftex-section-levels |
18050 | 1745 '( |
1746 ("part" . 0) | |
1747 ("chapter" . 1) | |
1748 ("section" . 2) | |
1749 ("subsection" . 3) | |
1750 ("subsubsection" . 4) | |
1751 ("paragraph" . 5) | |
1752 ("subparagraph" . 6) | |
1753 ("subsubparagraph" . 7) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1754 ) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1755 "Commands and levels used for defining sections in the document. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1756 The car of each cons cell is the name of the section macro. The cdr is a |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1757 number indicating its level." |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1758 :group 'reftex-defining-label-environments |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1759 :set 'reftex-set-dirty |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1760 :type '(repeat |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1761 (cons (string :tag "sectioning macro" "") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1762 (number :tag "level " 0)))) |
18050 | 1763 |
1764 (defun reftex-label (&optional environment no-insert) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1765 "Insert a unique label. Return the label. |
18050 | 1766 If ENVIRONMENT is given, don't bother to find out yourself. |
1767 If NO-INSERT is non-nil, do not insert label into buffer. | |
1768 With prefix arg, force to rescan document first. | |
1769 The label is also inserted into the label list. | |
1770 This function is controlled by the settings of reftex-insert-label-flags." | |
1771 | |
1772 (interactive) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1773 ;; Ensure access to scanning info and rescan buffer if prefix are is '(4). |
18050 | 1774 (reftex-access-scan-info current-prefix-arg) |
1775 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1776 ;; Find out what kind of environment this is and abort if necessary. |
18050 | 1777 (if (or (not environment) |
1778 (not (assoc environment reftex-env-or-mac-alist))) | |
1779 (setq environment (reftex-label-location))) | |
1780 (if (not environment) | |
1781 (error "Can't figure out what kind of label should be inserted")) | |
1782 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1783 ;; Ok, go ahead. |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1784 (let (label typekey prefix |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1785 entry format cell lab valid default force-prompt) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1786 (setq typekey (nth 1 (assoc environment reftex-env-or-mac-alist)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1787 format (nth 3 (assoc environment reftex-env-or-mac-alist))) |
18050 | 1788 (setq prefix (or (cdr (assoc typekey reftex-typekey-to-prefix-alist)) |
1789 (concat typekey "-"))) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1790 ;; Replace any escapes in the prefix |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1791 (setq prefix (reftex-replace-prefix-escapes prefix)) |
18050 | 1792 |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1793 ;; Make a default label. |
18050 | 1794 (cond |
1795 | |
1796 ((reftex-typekey-check typekey (nth 0 reftex-insert-label-flags)) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1797 ;; Derive a label from context. |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1798 (setq default (nth 2 (reftex-label-info " " nil nil t))) |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1799 ;; Catch the cases where the is actually no context available. |
18050 | 1800 (if (or (string-match "NO MATCH FOR CONTEXT REGEXP" default) |
1801 (string-match "ILLEGAL VALUE OF PARSE" default) | |
1802 (string-match "SECTION HEADING NOT FOUND" default) | |
1803 (string-match "HOOK ERROR" default) | |
1804 (string-match "^[ \t]*$" default)) | |
1805 (setq default prefix | |
1806 force-prompt t) ; need to prompt | |
1807 (setq default (concat prefix (reftex-string-to-label default))) | |
1808 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1809 ;; Make it unique. |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1810 (setq default (reftex-uniquify-label default nil "-")))) |
18050 | 1811 |
1812 ((reftex-typekey-check typekey (nth 1 reftex-insert-label-flags)) ; prompt | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1813 ;; Minimal default: the user will be prompted. |
18050 | 1814 (setq default prefix)) |
1815 | |
1816 (t | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1817 ;; Make an automatic label. |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1818 (setq default (reftex-uniquify-label prefix t)))) |
18050 | 1819 |
1820 ;; Should we ask the user? | |
1821 (if (or (reftex-typekey-check typekey | |
1822 (nth 1 reftex-insert-label-flags)) ; prompt | |
1823 force-prompt) | |
1824 | |
1825 (while (not valid) | |
1826 ;; iterate until we get a legal label | |
1827 | |
1828 (setq label (read-string "Label: " default)) | |
1829 | |
1830 ;; Lets make sure that this is a legal label | |
1831 (cond | |
1832 | |
1833 ;; Test if label contains strange characters | |
1834 ((string-match reftex-label-illegal-re label) | |
1835 (message "Label \"%s\" contains illegal characters" label) | |
1836 (ding) | |
1837 (sit-for 2)) | |
1838 | |
1839 ;; Look it up in the label list | |
1840 ((setq entry (assoc label | |
1841 (symbol-value reftex-list-of-labels-symbol))) | |
1842 (message "Label \"%s\" exists in file %s" label (nth 3 entry)) | |
1843 (ding) | |
1844 (sit-for 2)) | |
1845 | |
1846 ;; Label is ok | |
1847 (t | |
1848 (setq valid t)))) | |
1849 (setq label default)) | |
1850 | |
1851 ;; Insert the label | |
1852 (if (not no-insert) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1853 (insert (format format label))) |
18050 | 1854 |
1855 ;; Insert the label into the label list | |
1856 (if (symbol-value reftex-list-of-labels-symbol) | |
1857 (let ((cnt 0) | |
1858 (pos (point)) | |
1859 (all (symbol-value reftex-list-of-labels-symbol)) | |
1860 (look-for nil) | |
1861 (note nil) | |
1862 (text nil) | |
1863 (file (buffer-file-name))) | |
1864 | |
1865 ;; find the previous label in order to know where to insert new label | |
1866 ;; into label list | |
1867 (save-excursion | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1868 (if (re-search-backward "\\\\[a-z]*label{\\([^}]+\\)}" nil 1 2) |
18050 | 1869 (setq look-for (reftex-no-props (match-string 1)))) |
1870 (if (or (re-search-forward | |
1871 "\\\\\\(include\\|input\\){[^}\n]+}" pos t) | |
1872 (re-search-forward reftex-section-regexp pos t) | |
1873 (null look-for)) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
1874 (setq note "POSITION UNCERTAIN. RESCAN TO FIX."))) |
18050 | 1875 (if (not look-for) |
1876 (set reftex-list-of-labels-symbol | |
1877 (cons (list label typekey text file note) | |
1878 (symbol-value reftex-list-of-labels-symbol))) | |
1879 (while all | |
1880 (setq cell (car all) | |
1881 all (cdr all) | |
1882 cnt (1+ cnt) | |
1883 lab (nth 0 cell)) | |
1884 (if (string= lab look-for) | |
1885 (progn | |
1886 (setcdr | |
1887 (nthcdr (1- cnt) | |
1888 (symbol-value reftex-list-of-labels-symbol)) | |
1889 (cons (list label typekey text file note) | |
1890 (nthcdr | |
1891 cnt (symbol-value reftex-list-of-labels-symbol)))) | |
1892 ;; to end the loop, set all to nil | |
1893 (setq all nil))))))) | |
1894 ;; return value of the function is the label | |
1895 label)) | |
1896 | |
1897 (defun reftex-string-to-label (string) | |
1898 ;; Convert a string (a sentence) to a label. | |
1899 ;; | |
1900 ;; Uses reftex-derive-label-parameters and reftex-abbrev-parameters | |
1901 ;; | |
1902 | |
1903 (let* ((words0 (reftex-split "[- \t\n\r]+" | |
1904 (reftex-no-props string))) | |
1905 (ignore-words (nth 5 reftex-derive-label-parameters)) | |
1906 words word) | |
1907 | |
1908 ;; remove words from the ignore list or with funny characters | |
1909 (while words0 | |
1910 (setq word (car words0) words0 (cdr words0)) | |
1911 (cond | |
1912 ((member (downcase word) ignore-words)) | |
1913 ((string-match reftex-label-illegal-re word) | |
1914 (if (nth 2 reftex-derive-label-parameters) | |
1915 (progn | |
1916 (while (string-match reftex-label-illegal-re word) | |
1917 (setq word (replace-match "" nil nil word))) | |
1918 (setq words (cons word words))))) | |
1919 (t | |
1920 (setq words (cons word words))))) | |
1921 (setq words (nreverse words)) | |
1922 | |
1923 ;; restrict number of words | |
1924 (if (> (length words) (nth 0 reftex-derive-label-parameters)) | |
1925 (setcdr (nthcdr (1- (nth 0 reftex-derive-label-parameters)) words) nil)) | |
1926 | |
1927 ;; First, try to use all words | |
1928 (setq string (mapconcat '(lambda(w) w) words | |
1929 (nth 4 reftex-derive-label-parameters))) | |
1930 | |
1931 ;; Abbreviate words if enforced by user settings or string length | |
1932 (if (or (eq t (nth 3 reftex-derive-label-parameters)) | |
1933 (and (nth 3 reftex-derive-label-parameters) | |
1934 (> (length string) (nth 1 reftex-derive-label-parameters)))) | |
1935 (setq words | |
1936 (mapcar | |
1937 '(lambda (w) (if (string-match reftex-abbrev-regexp w) | |
1938 (match-string 1 w) | |
1939 w)) | |
1940 words) | |
1941 string (mapconcat '(lambda(w) w) words | |
1942 (nth 4 reftex-derive-label-parameters)))) | |
1943 | |
1944 ;; Shorten if still to long | |
1945 (setq string | |
1946 (if (> (length string) (nth 1 reftex-derive-label-parameters)) | |
1947 (substring string 0 (nth 1 reftex-derive-label-parameters)) | |
1948 string)) | |
1949 | |
1950 ;; Delete the final punctuation, if any | |
1951 (if (string-match "[^a-zA-Z0-9]+$" string) | |
1952 (setq string (replace-match "" nil nil string))) | |
1953 string)) | |
1954 | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1955 (defun reftex-replace-prefix-escapes (prefix) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1956 ;; Replace %escapes in a label prefix |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1957 (save-match-data |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1958 (let (letter (num 0) replace) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1959 (while (string-match "\\%\\([a-zA-Z]\\)" prefix num) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1960 (setq letter (match-string 1 prefix)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1961 (setq replace |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1962 (cond |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1963 ((equal letter "f") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1964 (file-name-sans-extension |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1965 (file-name-nondirectory (buffer-file-name)))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1966 ((equal letter "F") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1967 (let ((masterdir (file-name-directory (reftex-TeX-master-file))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1968 (file (file-name-sans-extension (buffer-file-name)))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1969 (if (string-match (concat "\\`" (regexp-quote masterdir)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1970 file) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1971 (substring file (length masterdir)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1972 file))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1973 ((equal letter "u") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1974 (or (user-login-name) "")) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1975 (t ""))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1976 (setq num (1- (+ (match-beginning 1) (length replace))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1977 prefix (replace-match replace nil nil prefix))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1978 prefix))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1979 |
18050 | 1980 (defun reftex-label-location (&optional bound) |
1981 ;; Return the environment or macro which determines the label type at point. | |
1982 ;; If optional BOUND is an integer, limit backward searches to that point. | |
1983 | |
1984 (let* ((loc1 (reftex-what-macro reftex-label-mac-list bound)) | |
1985 (loc2 (reftex-what-environment reftex-label-env-list bound)) | |
1986 (p1 (or (cdr loc1) 0)) | |
1987 (p2 (or (cdr loc2) 0))) | |
1988 | |
1989 (setq reftex-location-start (max p1 p2)) | |
1990 (if (> p1 p2) | |
1991 (progn | |
1992 (setq reftex-default-context-position p1) | |
1993 (car loc1)) | |
1994 (setq reftex-default-context-position | |
1995 (+ p2 8 (length (car loc2)))) | |
1996 (or (car loc2) "section")))) | |
1997 | |
1998 | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
1999 (defun reftex-uniquify-label (label &optional force separator) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2000 ;; Make label unique by appending a number. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2001 ;; Optional FORCE means, force appending a number, even if label is unique. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2002 ;; Optional SEPARATOR is a string to stick between label and number. |
18050 | 2003 |
2004 ;; Ensure access to scanning info | |
2005 (reftex-access-scan-info) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2006 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2007 (cond |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2008 ((and (not force) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2009 (not (assoc label (symbol-value reftex-list-of-labels-symbol)))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2010 label) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2011 (t |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2012 (let* ((cell (or (assoc label (symbol-value reftex-label-numbers-symbol)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2013 (car |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2014 (set reftex-label-numbers-symbol |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2015 (cons (cons label 0) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2016 (symbol-value reftex-label-numbers-symbol)))))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2017 (num (1+ (cdr cell))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2018 (sep (or separator ""))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2019 (while (assoc (concat label sep (int-to-string num)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2020 (symbol-value reftex-list-of-labels-symbol)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2021 (setq num (1+ num))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2022 (setcdr cell num) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2023 (concat label sep (int-to-string num)))))) |
18050 | 2024 |
2025 ;; Help string for the reference label menu | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2026 (defconst reftex-select-label-prompt |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2027 "Select: [n]ext [p]revious [r]escan [ ]context [q]uit RET [?]HELP+more") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2028 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2029 (defconst reftex-select-label-help |
18050 | 2030 " AVAILABLE KEYS IN REFERENCE LABEL MENU |
2031 ====================================== | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2032 n / p Go to next/previous label (Cursor motion works as well) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2033 C-s / C-r Search forward/backward. Use repeated C-s/C-r as in isearch. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2034 r / s Rescan document for labels / Switch label type |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2035 t / # Toggle table of contents / Toggle counter mode |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2036 c Toggle display of short context |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2037 SPC Show full context for current label in other window |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2038 f Toggle follow mode: other window will follow context |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2039 l / q Reuse last referenced label / Quit without accepting label |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2040 M-r Recursive Edit into other window |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2041 RET Accept current label") |
18050 | 2042 |
2043 (defun reftex-reference (&optional type no-insert) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
2044 "Make a LaTeX reference. Look only for labels of a certain TYPE. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
2045 With prefix arg, force to rescan buffer for labels. This should only be |
18050 | 2046 necessary if you have recently entered labels yourself without using |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
2047 reftex-label. Rescanning of the buffer can also be requested from the |
18050 | 2048 label selection menu. |
2049 The function returns the selected label or nil. | |
18123 | 2050 If NO-INSERT is non-nil, do not insert \\ref command, just return label. |
18050 | 2051 When called with 2 C-u prefix args, disable magic word recognition." |
2052 | |
2053 (interactive) | |
2054 | |
2055 ;; check for active recursive edits | |
2056 (reftex-check-recursive-edit) | |
2057 | |
2058 ;; Ensure access to scanning info and rescan buffer if prefix are is '(4) | |
2059 (reftex-access-scan-info current-prefix-arg) | |
2060 | |
2061 (if (not type) | |
2062 ;; guess type from context | |
2063 (if (and reftex-guess-label-type | |
2064 (not (= 16 (prefix-numeric-value current-prefix-arg))) | |
2065 (setq type (assoc (downcase (reftex-word-before-point)) | |
2066 reftex-words-to-typekey-alist))) | |
2067 (setq type (cdr type)) | |
2068 (setq type (reftex-query-label-type)))) | |
2069 | |
2070 (let (label pair | |
2071 (form (or (cdr (assoc type reftex-typekey-to-format-alist)) | |
2072 "\\ref{%s}"))) | |
2073 | |
2074 ;; Have the user select a label | |
2075 (setq pair (reftex-offer-label-menu type)) | |
2076 (setq label (car pair)) | |
2077 | |
2078 (if (and label | |
2079 (not no-insert)) | |
2080 (progn | |
2081 ;; do we need to remove spaces? | |
2082 (if (string= "~" (substring form 0 1)) | |
2083 (while (or (= (preceding-char) ?\ ) | |
2084 (= (preceding-char) ?\C-i)) | |
2085 (backward-delete-char 1))) | |
2086 ;; ok, insert the reference | |
2087 (insert (format form label label)) | |
2088 (message "")) | |
2089 (message "Quit")) | |
2090 ;; return the label | |
2091 label)) | |
2092 | |
2093 (defun reftex-goto-label (&optional arg) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
2094 "Go to a LaTeX label. With prefix ARG, go to label in another window." |
18050 | 2095 (interactive "P") |
2096 (let (type label file pair) | |
2097 (if (not type) | |
2098 (setq type (reftex-query-label-type))) | |
2099 | |
2100 (setq pair (reftex-offer-label-menu type) | |
2101 label (car pair) | |
2102 file (cdr pair)) | |
2103 (if (and label file (file-exists-p file)) | |
2104 (progn | |
2105 (if arg | |
2106 (find-file-other-window file) | |
2107 (find-file file)) | |
2108 (goto-char (point-min)) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2109 (if (not (re-search-forward |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2110 (concat "\\\\[a-z]*label{" (regexp-quote label) "}") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2111 nil t)) |
18050 | 2112 (error "No such label found: %s" label) |
2113 (reftex-highlight 0 (match-beginning 0) (match-end 0)) | |
2114 (add-hook 'pre-command-hook 'reftex-highlight-shall-die))) | |
2115 (message "Quit") | |
2116 nil))) | |
2117 | |
2118 ;; Internal list with index numbers of labels in the selection menu | |
2119 (defvar reftex-label-index-list nil) | |
2120 | |
2121 (defun reftex-offer-label-menu (typekey) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
2122 ;; Offer a menu with the appropriate labels. Return (label . file). |
18050 | 2123 (let* ((buf (current-buffer)) |
2124 (near-label (reftex-find-nearby-label)) | |
2125 (toc (reftex-typekey-check typekey reftex-label-menu-flags 0)) | |
2126 (context (not (reftex-typekey-check | |
2127 typekey reftex-label-menu-flags 3))) | |
2128 (counter (reftex-typekey-check | |
2129 typekey reftex-label-menu-flags 2)) | |
2130 (follow (reftex-typekey-check | |
2131 typekey reftex-label-menu-flags 4)) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2132 (match-everywhere (reftex-typekey-check |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2133 typekey reftex-label-menu-flags 6)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2134 offset rtn key cnt last-cnt entry) |
18050 | 2135 |
2136 (setq reftex-call-back-to-this-buffer buf) | |
2137 (setq entry (cons nil nil)) | |
2138 | |
2139 (unwind-protect | |
2140 (catch 'exit | |
2141 (while t | |
2142 (save-window-excursion | |
2143 (switch-to-buffer-other-window "*RefTeX Select*") | |
2144 (erase-buffer) | |
2145 (setq truncate-lines t) | |
2146 (setq reftex-label-index-list (reftex-make-and-insert-label-list | |
2147 typekey buf toc context counter | |
2148 near-label)) | |
2149 (setq near-label "_ ") ; turn off search for near label | |
2150 (setq offset (or (car reftex-label-index-list) offset)) | |
2151 ;; use only when searched | |
2152 (setq reftex-label-index-list (cdr reftex-label-index-list)) | |
2153 ;; only this is the true list | |
2154 (if (not reftex-label-index-list) | |
2155 (error "No labels of type \"%s\"" typekey)) | |
2156 (setq rtn | |
2157 (reftex-select-item | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2158 reftex-select-label-prompt |
18050 | 2159 "^>" |
2160 2 | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2161 reftex-select-label-help |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2162 '(?r ?g ?c ?t ?s ?# ?l) |
18050 | 2163 offset |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2164 'reftex-select-label-callback follow |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2165 match-everywhere)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2166 (setq key (car rtn) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2167 cnt (nth 1 rtn) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2168 last-cnt (nth 2 rtn) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2169 offset (1+ (or cnt last-cnt))) |
18050 | 2170 (if (not key) (throw 'exit nil)) |
2171 (cond | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2172 ((or (eq key ?r) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2173 (eq key ?g)) |
18050 | 2174 ;; rescan buffer |
2175 (reftex-parse-document buf)) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2176 ((eq key ?c) |
18050 | 2177 ;; toggle context mode |
2178 (setq context (not context))) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2179 ((eq key ?s) |
18050 | 2180 ;; switch type |
2181 (setq typekey (reftex-query-label-type))) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2182 ((eq key ?t) |
18050 | 2183 ;; toggle tabel of contents display |
2184 (setq toc (not toc))) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2185 ((eq key ?#) |
18050 | 2186 ;; toggle counter display |
2187 (setq counter (not counter))) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2188 ((eq key ?l) |
18050 | 2189 ;; reuse the last referenced label again |
2190 (setq entry reftex-last-used-reference) | |
2191 (throw 'exit t)) | |
2192 (t | |
2193 (set-buffer buf) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2194 (if cnt |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2195 (progn |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2196 (setq entry (nth (nth cnt reftex-label-index-list) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2197 (symbol-value reftex-list-of-labels-symbol))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2198 (setq reftex-last-used-reference entry)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2199 (setq entry nil)) |
18050 | 2200 (throw 'exit t)))))) |
2201 (kill-buffer "*RefTeX Select*") | |
2202 (reftex-kill-temporary-buffers)) | |
2203 (cons (reftex-no-props (nth 0 entry)) (nth 3 entry)))) | |
2204 | |
2205 ;; Indentation for table of context lines in the menu | |
2206 (defconst reftex-toc-indent " ") | |
2207 ;; Indentation for the lines containing the label | |
2208 (defconst reftex-label-indent "> ") | |
2209 ;; Indentation for context lines | |
2210 (defconst reftex-context-indent ". ") | |
2211 ;; Indentation per section level | |
2212 (defvar reftex-level-indent 2 | |
2213 "*Number of spaces to be used for indentation per section level. | |
2214 With more indentation, the label menu looks nicer, but shows less context. | |
2215 Changing this is only fully operational after the next buffer scan.") | |
2216 | |
2217 (defun reftex-make-and-insert-label-list (typekey0 buf toc context | |
2218 counter near-label) | |
2219 ;; Insert a menu of all labels in buffer BUF into current buffer. | |
2220 ;; Return the list of labels, with the index of NEAR-LABEL as extra car. | |
2221 (let (ins-list index-list offset) | |
2222 (save-excursion | |
2223 (set-buffer buf) | |
2224 (let* ((all nil) | |
2225 (font (reftex-use-fonts)) | |
2226 (cnt 0) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2227 ;; (file nil) |
18050 | 2228 (index -1) |
2229 (toc-indent reftex-toc-indent) | |
2230 (label-indent | |
2231 (concat reftex-label-indent | |
2232 (if toc (make-string (* 7 reftex-level-indent) ?\ ) ""))) | |
2233 (context-indent | |
2234 (concat reftex-context-indent | |
2235 (if toc (make-string (* 7 reftex-level-indent) ?\ ) ""))) | |
2236 cell text label typekey note comment) | |
2237 | |
2238 ; Ensure access to scanning info | |
2239 (reftex-access-scan-info) | |
2240 | |
2241 (setq all (symbol-value reftex-list-of-labels-symbol)) | |
2242 | |
2243 (while all | |
2244 | |
2245 (setq index (1+ index) | |
2246 cell (car all) | |
2247 all (cdr all)) | |
2248 | |
2249 (if (null (nth 2 cell)) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
2250 ;; No context yet. Quick update |
18050 | 2251 (progn |
2252 (setq cell (reftex-label-info-update cell)) | |
2253 (setcar (nthcdr index | |
2254 (symbol-value reftex-list-of-labels-symbol)) | |
2255 cell))) | |
2256 | |
2257 ;; in the following setq we *copy* the label, since we will change | |
2258 ;; its properties, and we cannot have any properties in the list | |
2259 ;; (because of assoc searches) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2260 (setq label (if (stringp (car cell)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2261 (copy-sequence (car cell)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2262 (car cell)) |
18050 | 2263 typekey (nth 1 cell) |
2264 text (nth 2 cell) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2265 ;; file (nth 3 cell) |
18050 | 2266 note (nth 4 cell) |
2267 comment (get-text-property 0 'in-comment text)) | |
2268 | |
2269 (if (string= label near-label) | |
2270 (setq offset (1+ cnt))) | |
2271 | |
2272 (cond | |
2273 ((and toc (string= typekey "toc")) | |
2274 (setq ins-list | |
2275 (cons (concat toc-indent text "\n") | |
2276 ins-list))) | |
2277 ((string= typekey "toc")) | |
2278 ((and (or (string= typekey typekey0) (string= typekey0 " ")) | |
2279 (or (nth 5 reftex-label-menu-flags) ; show-commented? | |
2280 (null comment))) | |
2281 (setq cnt (1+ cnt)) | |
2282 (if comment (setq label (concat "% " label))) | |
2283 (if font | |
2284 (put-text-property | |
2285 0 (length label) | |
2286 'face | |
2287 (if comment | |
2288 'font-lock-comment-face | |
2289 'font-lock-reference-face) | |
2290 label)) | |
2291 (setq index-list (cons index index-list)) | |
2292 (setq ins-list | |
2293 (cons (concat | |
2294 label-indent | |
2295 label | |
2296 (if counter (format " (%d) " cnt)) | |
2297 (if comment " LABEL IS COMMENTED OUT ") | |
2298 (if note (concat " " note) "") | |
2299 "\n" | |
2300 (if context (concat context-indent text "\n"))) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2301 ins-list)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2302 (put-text-property 0 (length (car ins-list)) 'cnt (1- cnt) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2303 (car ins-list)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2304 )) |
18050 | 2305 ))) |
2306 | |
2307 (apply 'insert (nreverse ins-list)) | |
2308 (cons offset (nreverse index-list)))) | |
2309 | |
2310 (defun reftex-query-label-type () | |
2311 ;; Ask for label type | |
2312 (message reftex-type-query-prompt) | |
2313 (let ((key (read-char))) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2314 (if (eq key ?\?) |
18050 | 2315 (progn |
2316 (save-window-excursion | |
2317 (with-output-to-temp-buffer "*RefTeX Help*" | |
2318 (princ reftex-type-query-help)) | |
2319 (setq key (read-char)) | |
2320 (kill-buffer "*RefTeX Help*")))) | |
2321 (if (not (member (char-to-string key) reftex-typekey-list)) | |
2322 (error "No such label type: %s" (char-to-string key))) | |
2323 (char-to-string key))) | |
2324 | |
2325 (defun reftex-find-nearby-label () | |
2326 ;; Find a nearby label. | |
2327 (save-excursion | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2328 (if (or (re-search-backward "\\\\[a-z]*label{\\([^}]+\\)}" nil t) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2329 (re-search-forward "\\\\[a-z]*label{\\([^}]+\\)}" nil t)) |
18050 | 2330 (reftex-no-props (match-string 1)) |
2331 nil))) | |
2332 | |
2333 ;; Variable holding the vector with section numbers | |
2334 (defvar reftex-section-numbers [0 0 0 0 0 0 0 0]) | |
2335 | |
2336 (defun reftex-scan-buffer-for-labels (label-numbers-symbol label-list-symbol) | |
2337 ;; Scan the buffer for labels and save them in a list. | |
2338 (save-excursion | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2339 (let ((regexp (concat "\\\\[a-z]*label{\\([^}]*\\)}" "\\|" |
18050 | 2340 reftex-section-regexp)) |
2341 (font (reftex-use-fonts)) | |
2342 (bound 0) | |
2343 (highest-level 100) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2344 file (level 1) star text text1 label section-number macro find) |
18050 | 2345 (set label-list-symbol nil) |
2346 (goto-char 0) | |
2347 | |
2348 ;; reset label numbers | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2349 (set label-numbers-symbol nil) |
18050 | 2350 |
2351 ;; reset section numbers | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2352 (reftex-init-section-numbers reftex-section-numbers) |
18050 | 2353 |
2354 (while (re-search-forward regexp nil t) | |
2355 (setq file (get-text-property (match-beginning 0) 'file)) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2356 (if (match-string 1) |
18050 | 2357 ;; It is a label |
2358 (progn | |
2359 (setq label (reftex-no-props (match-string 1))) | |
2360 (set label-list-symbol | |
2361 (cons (reftex-label-info label file bound) | |
2362 (symbol-value label-list-symbol)))) | |
2363 | |
2364 ;; It is a section | |
2365 (setq bound (point)) | |
2366 (setq star (= ?* (char-after (match-end 2)))) | |
2367 (setq find (buffer-substring-no-properties | |
2368 (1- (match-beginning 2)) (match-end 0))) | |
2369 (setq macro (reftex-no-props (match-string 2))) | |
2370 (setq level (cdr (assoc macro reftex-section-levels))) | |
2371 | |
2372 (setq section-number (reftex-section-number | |
2373 reftex-section-numbers level star)) | |
2374 (setq highest-level (min highest-level level)) | |
2375 (if (= level highest-level) | |
2376 (message | |
2377 "Scanning %s %s ..." | |
2378 (car (nth level reftex-section-levels)) | |
2379 section-number)) | |
2380 | |
2381 ;; get the title | |
2382 (save-match-data | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2383 (save-excursion |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2384 (setq text1 (reftex-context-substring)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2385 (setq text (reftex-nicify-text text1)))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2386 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2387 (setq find |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2388 (reftex-allow-for-ctrl-m |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2389 (concat find text1 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2390 (char-to-string |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2391 (char-after (+ (match-end 0) (length text1))))))) |
18050 | 2392 |
2393 ;; add section number and indentation | |
2394 (setq text | |
2395 (concat | |
2396 (make-string (* reftex-level-indent level) ?\ ) | |
2397 (if (nth 1 reftex-label-menu-flags) ; section number flag | |
2398 (concat section-number " ")) | |
2399 text)) | |
2400 ;; fontify | |
2401 (if font (put-text-property 0 (length text) | |
2402 'face 'font-lock-comment-face text)) | |
2403 | |
2404 ;; insert in list | |
2405 (set label-list-symbol | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2406 (cons (list 'toc "toc" text file find level section-number) |
18050 | 2407 (symbol-value label-list-symbol))))) |
2408 (set label-list-symbol | |
2409 (nreverse (symbol-value label-list-symbol)))))) | |
2410 | |
2411 (defun reftex-label-info-update (cell) | |
2412 ;; Update information about just one label in a different file. | |
2413 ;; CELL contains the old info list | |
2414 (let* ((label (nth 0 cell)) | |
2415 (typekey (nth 1 cell)) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2416 ;; (text (nth 2 cell)) |
18050 | 2417 (file (nth 3 cell)) |
2418 (note (nth 4 cell)) | |
2419 (buf (reftex-get-file-buffer-force | |
2420 file (not reftex-keep-temporary-buffers)))) | |
2421 (if (not buf) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
2422 (list label typekey "" file "LOST LABEL. RESCAN TO FIX.") |
18050 | 2423 (save-excursion |
2424 (set-buffer buf) | |
2425 (save-restriction | |
2426 (widen) | |
2427 (goto-char 1) | |
2428 | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2429 (if (re-search-forward (concat "\\\\[a-z]*label{" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2430 (regexp-quote label) "}") |
18050 | 2431 nil t) |
2432 (append (reftex-label-info label file) (list note)) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
2433 (list label typekey "" file "LOST LABEL. RESCAN TO FIX."))))))) |
18050 | 2434 |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2435 (defun reftex-label-info (label &optional file bound derive) |
18050 | 2436 ;; Return info list on LABEL at point. |
2437 (let* ((env-or-mac (reftex-label-location bound)) | |
2438 (typekey (nth 1 (assoc env-or-mac reftex-env-or-mac-alist))) | |
2439 (file (or file (buffer-file-name))) | |
2440 (parse (if (reftex-typekey-check | |
2441 typekey reftex-use-text-after-label-as-context) | |
2442 nil | |
2443 (nth 2 (assoc env-or-mac reftex-env-or-mac-alist)))) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2444 (text (reftex-short-context env-or-mac parse reftex-location-start |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2445 derive))) |
18050 | 2446 (if (reftex-in-comment) |
2447 (put-text-property 0 1 'in-comment t text)) | |
2448 (list label typekey text file))) | |
2449 | |
2450 (defun reftex-in-comment () | |
2451 (save-excursion | |
2452 (skip-chars-backward "^%\n\r") | |
2453 (= (preceding-char) ?%))) | |
2454 | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2455 (defun reftex-short-context (env parse &optional bound derive) |
18050 | 2456 ;; Get about one line of useful context for the label definition at point. |
2457 | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2458 (if (consp parse) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2459 (setq parse (if derive (cdr parse) (car parse)))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2460 |
18050 | 2461 (reftex-nicify-text |
2462 | |
2463 (cond | |
2464 | |
2465 ((null parse) | |
2466 (save-excursion | |
2467 (reftex-context-substring))) | |
2468 | |
2469 ((eq parse t) | |
2470 (if (string= env "section") | |
2471 ;; special treatment for section labels | |
2472 (save-excursion | |
2473 (if (re-search-backward reftex-section-regexp (point-min) t) | |
2474 (progn | |
2475 (goto-char (match-end 0)) | |
2476 (reftex-context-substring)) | |
2477 "SECTION HEADING NOT FOUND")) | |
2478 (save-excursion | |
2479 (goto-char reftex-default-context-position) | |
2480 (reftex-context-substring)))) | |
2481 | |
2482 ((stringp parse) | |
2483 (save-excursion | |
2484 (if (re-search-backward parse bound t) | |
2485 (progn | |
2486 (goto-char (match-end 0)) | |
2487 (reftex-context-substring)) | |
2488 "NO MATCH FOR CONTEXT REGEXP"))) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2489 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2490 ((integerp parse) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2491 (save-excursion |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2492 (goto-char reftex-default-context-position) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2493 (reftex-nth-parens-substring parse))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2494 |
18050 | 2495 ((fboundp parse) |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
2496 ;; A hook function. Call it. |
18050 | 2497 (save-excursion |
2498 (condition-case error-var | |
2499 (funcall parse env) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2500 (error (format "HOOK ERROR: %s" (cdr error-var)))))) |
18050 | 2501 (t |
2502 "ILLEGAL VALUE OF PARSE")))) | |
2503 | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2504 (defun reftex-nth-parens-substring (n) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2505 ;; Return the nth following {} or [] parentheses content. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2506 ;; If we are sitting at a macro start, skip to ent of macro name. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2507 (and (eq (following-char) ?\\) (skip-chars-forward "a-zA-Z*\\\\")) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2508 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2509 ;; Skip parenthesis pairs. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2510 (while (and (> (setq n (1- n)) 0) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2511 (or (eq (following-char) ?{) (eq (following-char) ?\[)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2512 (condition-case nil (or (forward-list 1) t) (error nil)))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2513 (skip-chars-forward "{\\[") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2514 (reftex-context-substring)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2515 |
18050 | 2516 (defun reftex-context-substring () |
2517 ;; Return up to 100 chars from point | |
2518 ;; When point is just after a { or [, limit string to matching parenthesis | |
2519 (cond | |
2520 ((or (= (preceding-char) ?\{) | |
2521 (= (preceding-char) ?\[)) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2522 ;; Inside a list - get only the list. |
18050 | 2523 (buffer-substring |
2524 (point) | |
2525 (min (+ 100 (point)) | |
2526 (point-max) | |
2527 (condition-case nil | |
2528 (progn | |
2529 (up-list 1) | |
2530 (1- (point))) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2531 (error (point-max)))))) |
18050 | 2532 (t |
2533 ;; no list - just grab 100 characters | |
2534 (buffer-substring (point) (min (+ 100 (point)) (point-max)))))) | |
2535 | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2536 (defun reftex-init-section-numbers (section-numbers &optional toc-entry) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2537 ;; Initialize the section numbers with zeros or with what is found |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2538 ;; in the toc entry. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2539 (let* ((level (or (nth 5 toc-entry) -1)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2540 (numbers (nreverse (reftex-split "\\." (or (nth 6 toc-entry) "")))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2541 (depth (1- (length section-numbers))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2542 (i depth)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2543 (while (>= i 0) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2544 (if (> i level) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2545 (aset section-numbers i 0) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2546 (aset section-numbers i (string-to-int (or (car numbers) "0"))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2547 (setq numbers (cdr numbers))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2548 (setq i (1- i))))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2549 |
18050 | 2550 (defun reftex-section-number (section-numbers &optional level star) |
2551 ;; Return a string with the current section number. | |
2552 ;; When LEVEL is non-nil, increase section numbers on that level. | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2553 (let* ((depth (1- (length section-numbers))) idx n (string "")) |
18050 | 2554 (if level |
2555 (progn | |
2556 (if (and (> level -1) (not star)) | |
2557 (aset section-numbers level (1+ (aref section-numbers level)))) | |
2558 (setq idx (1+ level)) | |
2559 (while (<= idx depth) | |
2560 (aset section-numbers idx 0) | |
2561 (setq idx (1+ idx))))) | |
2562 (setq idx 0) | |
2563 (while (<= idx depth) | |
2564 (setq n (aref section-numbers idx)) | |
2565 (setq string (concat string (if (not (string= string "")) "." "") | |
2566 (int-to-string n))) | |
2567 (setq idx (1+ idx))) | |
2568 (save-match-data | |
2569 (if (string-match "\\`\\(0\\.\\)+" string) | |
2570 (setq string (replace-match "" nil nil string))) | |
2571 (if (string-match "\\(\\.0\\)+\\'" string) | |
2572 (setq string (replace-match "" nil nil string)))) | |
2573 (if star | |
2574 (concat (make-string (1- (length string)) ?\ ) "*") | |
2575 string))) | |
2576 | |
2577 ;; A variable to remember the index of the last label context shown | |
2578 (defvar reftex-last-cnt 0) | |
2579 | |
2580 (defun reftex-select-label-callback (cnt) | |
2581 ;; Callback function called from the label selection in order to | |
2582 ;; show context in another window | |
2583 (let* ((this-window (selected-window)) | |
2584 index entry label file buffer) | |
2585 ;; pop to original buffer in order to get correct variables | |
2586 (catch 'exit | |
2587 (save-excursion | |
2588 (set-buffer reftex-call-back-to-this-buffer) | |
2589 (setq index (nth (or cnt 1) reftex-label-index-list) | |
2590 entry (nth index (symbol-value reftex-list-of-labels-symbol)) | |
2591 label (nth 0 entry) | |
2592 file (nth 3 entry))) | |
2593 | |
2594 ;; goto the file in another window | |
2595 (setq buffer (reftex-get-file-buffer-force | |
2596 file (not reftex-keep-temporary-buffers))) | |
2597 (if buffer | |
2598 ;; good - the file is available | |
2599 (switch-to-buffer-other-window buffer) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
2600 ;; we have got a problem here. The file does not exist. |
18050 | 2601 ;; Let' get out of here.. |
2602 (ding) | |
2603 (throw 'exit nil)) | |
2604 | |
2605 | |
2606 ;; search for that label | |
2607 (if (not (and (integerp cnt) | |
2608 (integerp reftex-last-cnt) | |
2609 (if (> cnt reftex-last-cnt) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2610 (re-search-forward |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2611 (concat "\\\\[a-z]*label{" (regexp-quote label) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2612 "}") nil t) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2613 (re-search-backward |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2614 (concat "\\\\[a-z]*label{" (regexp-quote label) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2615 "}") nil t)))) |
18050 | 2616 (progn |
2617 (goto-char 1) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2618 (re-search-forward (concat "\\\\[a-z]*label{" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2619 (regexp-quote label) "}") nil t))) |
18050 | 2620 (reftex-highlight 0 (match-beginning 0) (match-end 0)) |
2621 (reftex-show-entry) | |
2622 (recenter (/ (window-height) 2)) | |
2623 (select-window this-window)))) | |
2624 | |
2625 (defun reftex-pop-to-label (label file-list &optional mark-to-kill highlight) | |
2626 ;; Find LABEL in any file in FILE-LIST in another window. | |
2627 ;; If mark-to-kill is non-nil, mark new buffer for killing. | |
2628 ;; If HIGHLIGHT is non-nil, highlight the label definition. | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2629 (let* ((re (concat "\\\\[a-z]*label{" (regexp-quote label) "}")) |
18050 | 2630 file buf) |
2631 (catch 'exit | |
2632 (while file-list | |
2633 (setq file (car file-list) | |
2634 file-list (cdr file-list)) | |
2635 (if (not (setq buf (reftex-get-file-buffer-force file mark-to-kill))) | |
2636 (error "No such file %s" file)) | |
2637 (set-buffer buf) | |
2638 (widen) | |
2639 (goto-char (point-min)) | |
2640 (if (re-search-forward re nil t) | |
2641 (progn | |
2642 (switch-to-buffer-other-window buf) | |
2643 (goto-char (match-beginning 0)) | |
2644 (recenter (/ (window-height) 2)) | |
2645 (if highlight | |
2646 (reftex-highlight 0 (match-beginning 0) (match-end 0))) | |
2647 (throw 'exit (selected-window))))) | |
2648 (error "Label %s not found" label)))) | |
2649 | |
2650 (defun reftex-find-duplicate-labels () | |
2651 "Produce a list of all duplicate labels in the document." | |
2652 | |
2653 (interactive) | |
2654 | |
2655 ;; Rescan the document to make sure | |
2656 (reftex-access-scan-info t) | |
2657 | |
2658 (let ((master (reftex-TeX-master-file)) | |
2659 (dlist | |
2660 (mapcar | |
2661 '(lambda(x) | |
2662 (let (x1) | |
2663 (cond | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2664 ((memq (car x) '(toc bof eof)) nil) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2665 (t |
18050 | 2666 (setq x1 (reftex-all-assoc-string |
2667 (car x) (symbol-value reftex-list-of-labels-symbol))) | |
2668 (if (< 1 (length x1)) | |
2669 (append (list (reftex-no-props (car x))) | |
2670 (mapcar '(lambda(x) | |
2671 (abbreviate-file-name (nth 3 x))) x1)) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2672 (list nil)))))) |
18050 | 2673 (reftex-uniquify (symbol-value reftex-list-of-labels-symbol))))) |
2674 (setq dlist (reftex-uniquify dlist)) | |
2675 (if (null dlist) (error "No duplicate labels in document")) | |
18219
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
2676 (switch-to-buffer-other-window "*Duplicate Labels*") |
18050 | 2677 (make-local-variable 'TeX-master) |
2678 (setq TeX-master master) | |
2679 (erase-buffer) | |
2680 (insert " MULTIPLE LABELS IN CURRENT DOCUMENT:\n") | |
2681 (insert " Move point to label and type `M-x reftex-change-label'\n" | |
2682 " This will run a query-replace on the label and its references\n") | |
2683 (insert " LABEL FILE\n") | |
2684 (insert " -------------------------------------------------------------\n") | |
2685 (while dlist | |
2686 (if (and (car (car dlist)) | |
2687 (cdr (car dlist))) | |
2688 (progn | |
2689 (insert (mapconcat '(lambda(x) x) (car dlist) "\n ") "\n"))) | |
2690 (setq dlist (cdr dlist))) | |
2691 (goto-char (point-min)))) | |
2692 | |
2693 (defun reftex-all-assoc-string (key list) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
2694 ;; Return a list of all associations of KEY in LIST. Comparison with string= |
18050 | 2695 (let (rtn) |
2696 (while list | |
2697 (if (string= (car (car list)) key) | |
2698 (setq rtn (cons (car list) rtn))) | |
2699 (setq list (cdr list))) | |
2700 (nreverse rtn))) | |
2701 | |
2702 (defun reftex-kill-temporary-buffers () | |
2703 ;; Kill all buffers in the list reftex-kill-temporary-buffers. | |
2704 (while reftex-buffers-to-kill | |
2705 (if (bufferp (car reftex-buffers-to-kill)) | |
2706 (progn | |
2707 (and (buffer-modified-p (car reftex-buffers-to-kill)) | |
2708 (y-or-n-p (format "Save file %s? " | |
2709 (buffer-file-name | |
2710 (car reftex-buffers-to-kill)))) | |
2711 (save-excursion | |
2712 (set-buffer (car reftex-buffers-to-kill)) | |
2713 (save-buffer))) | |
2714 (kill-buffer (car reftex-buffers-to-kill)))) | |
2715 (setq reftex-buffers-to-kill (cdr reftex-buffers-to-kill)))) | |
2716 | |
2717 (defun reftex-show-entry () | |
2718 ;; Show entry if point is hidden by outline mode | |
2719 (let ((pos (point))) | |
2720 (if (and reftex-auto-show-entry | |
2721 (boundp 'outline-minor-mode) | |
2722 outline-minor-mode | |
2723 (looking-at "[^\n\r]*\r")) | |
2724 (progn | |
2725 (outline-back-to-heading) | |
2726 (show-entry) | |
2727 (goto-char pos))))) | |
2728 | |
2729 | |
2730 (defun reftex-nicify-text (text) | |
2731 ;; Make TEXT nice for inclusion into label menu | |
2732 (while (string-match "[\n\r\t]\\|[ \t][ \t]+" text) ; remove extra whitespace | |
2733 (setq text (replace-match " " nil t text))) | |
2734 (if (string-match "\\\\end{.*" text) ; nothing beyond \end{ | |
2735 (setq text (replace-match "" nil t text))) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2736 (if (string-match "\\\\[a-z]*label{[^}]*}" text) ; kill the label |
18050 | 2737 (setq text (replace-match "" nil t text))) |
2738 (if (string-match "^ +" text) ; leading whitespace | |
2739 (setq text (replace-match "" nil t text))) | |
2740 (cond | |
2741 ((> (length text) 100) ; not to long | |
2742 (setq text (substring text 0 100))) | |
2743 ((= (length text) 0) ; not empty | |
2744 (setq text " "))) | |
2745 text) | |
2746 | |
2747 (defun reftex-typekey-check (typekey conf-variable &optional n) | |
2748 ;; Check if CONF-VARIABLE is true or contains TYPEKEY | |
2749 (and n (setq conf-variable (nth n conf-variable))) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2750 (or (eq conf-variable t) |
18050 | 2751 (and (stringp conf-variable) |
2752 (string-match (concat "[" conf-variable "]") typekey)))) | |
2753 | |
2754 ;;; =========================================================================== | |
2755 ;;; | |
2756 ;;; Table of contents (contributed from Stephen Eglen, changed by C. Dominik) | |
2757 | |
2758 ;; We keep at most one *toc* buffer - it is easy to make them | |
2759 | |
2760 (defvar reftex-last-toc-master nil | |
2761 "Stores the name of the tex file that `reftex-toc' was last run on.") | |
2762 | |
2763 (defvar reftex-last-toc-file nil | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
2764 "Stores the file name from which `reftex-toc' was called. For redo command.") |
18050 | 2765 |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2766 (defvar reftex-last-window-height nil) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2767 |
18050 | 2768 (defvar reftex-toc-return-marker (make-marker) |
2769 "Marker which makes it possible to return from toc to old position.") | |
2770 | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2771 (defconst reftex-toc-help |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2772 " AVAILABLE KEYS IN TOC BUFFER |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2773 ============================ |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2774 SPC Show the corresponding section of the LaTeX document. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2775 TAB Goto the section. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2776 RET Goto the section and hide the *toc* buffer (also on mouse-2). |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2777 q / Q Hide/Kill *toc* buffer, return to position of last reftex-toc command. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2778 f Toggle follow mode on and off. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2779 r / g Reparse the LaTeX document.") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2780 |
18050 | 2781 (defun reftex-toc () |
2782 "Show the table of contents for the current document. | |
2783 When called with a raw C-u prefix, rescan the document first." | |
2784 | |
2785 (interactive) | |
2786 | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2787 (if (or (not (string= reftex-last-toc-master (reftex-TeX-master-file))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2788 current-prefix-arg) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2789 (reftex-empty-toc-buffer)) |
18050 | 2790 |
2791 (setq reftex-last-toc-file (buffer-file-name)) | |
2792 (setq reftex-last-toc-master (reftex-TeX-master-file)) | |
2793 | |
2794 (set-marker reftex-toc-return-marker (point)) | |
2795 | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2796 ;; If follow mode is active, arrange to delay it one command |
18050 | 2797 (if reftex-toc-follow-mode |
2798 (setq reftex-toc-follow-mode 1)) | |
2799 | |
2800 ;; Ensure access to scanning info and rescan buffer if prefix are is '(4) | |
2801 (reftex-access-scan-info current-prefix-arg) | |
2802 | |
2803 (let* ((all (symbol-value reftex-list-of-labels-symbol)) | |
2804 (where (reftex-nearest-section)) | |
2805 toc toc1 cell label file find startpos) | |
2806 | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2807 (if (get-buffer-window "*toc*") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2808 (select-window (get-buffer-window "*toc*")) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2809 (setq reftex-last-window-height (window-height)) ; remember |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2810 (split-window-vertically) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2811 (switch-to-buffer (get-buffer-create "*toc*"))) |
18050 | 2812 |
2813 (cond | |
2814 ;; buffer is empty - fill it with the table of contents | |
2815 ((= (buffer-size) 0) | |
2816 | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2817 (local-set-key "?" 'reftex-toc-show-help) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2818 (local-set-key " " 'reftex-toc-view-line) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2819 (local-set-key "\C-m" 'reftex-toc-goto-line-and-hide) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2820 (local-set-key "\C-i" 'reftex-toc-goto-line) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2821 (local-set-key "r" 'reftex-toc-redo) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2822 (local-set-key "g" 'revert-buffer) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2823 (local-set-key "q" 'reftex-toc-quit) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2824 (local-set-key "Q" 'reftex-toc-quit-and-kill) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2825 (local-set-key "f" 'reftex-toc-toggle-follow) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2826 (local-set-key [(mouse-2)] 'reftex-toc-mouse-goto-line-and-hide); Emacs |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2827 (local-set-key [(button2)] 'reftex-toc-mouse-goto-line-and-hide); XEmacs |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
2828 (make-local-variable 'revert-buffer-function) |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
2829 (setq revert-buffer-function 'reftex-toc-redo) |
18050 | 2830 (setq truncate-lines t) |
2831 (make-local-hook 'post-command-hook) | |
2832 (make-local-hook 'pre-command-hook) | |
2833 (setq post-command-hook '(reftex-toc-post-command-hook)) | |
2834 (setq pre-command-hook '(reftex-toc-pre-command-hook)) | |
2835 | |
2836 (insert (format | |
2837 "TABLE-OF-CONTENTS on %s | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2838 SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [f]ollow-mode [?]Help |
18050 | 2839 ------------------------------------------------------------------------------- |
2840 " (abbreviate-file-name reftex-last-toc-master))) | |
2841 (setq startpos (point)) | |
2842 | |
2843 (if (reftex-use-fonts) | |
2844 (put-text-property 1 (point) 'face 'font-lock-keyword-face)) | |
2845 (put-text-property 1 (point) 'intangible t) | |
2846 | |
2847 (while all | |
2848 (setq cell (car all) | |
2849 all (cdr all)) | |
2850 (setq label (nth 0 cell) | |
2851 toc (nth 2 cell) | |
2852 file (nth 3 cell) | |
2853 find (nth 4 cell)) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2854 (if (eq label 'toc) |
18050 | 2855 (progn |
2856 (setq toc1 (concat toc "\n")) | |
2857 (put-text-property 0 (length toc1) | |
2858 'file file toc1) | |
2859 (put-text-property 0 (length toc1) | |
2860 'find find toc1) | |
2861 (insert toc1) | |
2862 ))) | |
2863 | |
2864 (backward-delete-char 1) | |
2865 | |
2866 (setq buffer-read-only t)) | |
2867 (t | |
2868 (goto-line 3) | |
2869 (beginning-of-line) | |
2870 (setq startpos (point)))) | |
2871 | |
2872 ;; Find the correct section | |
2873 (goto-char (point-max)) | |
2874 (beginning-of-line) | |
2875 (while (and (> (point) startpos) | |
2876 (or (not (string= (get-text-property (point) 'file) | |
2877 (car where))) | |
2878 (not (string= (get-text-property (point) 'find) | |
2879 (cdr where))))) | |
2880 (beginning-of-line 0)))) | |
2881 | |
2882 (defun reftex-nearest-section () | |
2883 ;; Return (file . find) of nearest section command | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2884 (let (cell label rest pos text1 text2) |
18050 | 2885 (save-excursion |
2886 (cond | |
2887 ;; Try to find a section heading | |
2888 ((or (re-search-backward reftex-section-regexp nil t) | |
2889 (re-search-forward reftex-section-regexp nil t)) | |
2890 (goto-char (match-end 0)) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2891 (setq pos (point) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2892 text1 (buffer-substring-no-properties |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2893 (1- (match-beginning 1)) (match-end 0)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2894 text2 (reftex-context-substring)) |
18050 | 2895 (cons (buffer-file-name) |
2896 (reftex-allow-for-ctrl-m | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2897 (concat text1 text2 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2898 (char-to-string |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2899 (char-after (+ pos (length text2)))))))) |
18050 | 2900 ;; Try to find a label |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2901 ((and (or (re-search-backward "\\\\[a-z]*label{\\([^}]+\\)}" nil t) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2902 (re-search-forward "\\\\[a-z]*label{\\([^}]+\\)}" nil t)) |
18050 | 2903 (setq label (reftex-no-props (match-string 1))) |
2904 (setq cell (assoc label (symbol-value | |
2905 reftex-list-of-labels-symbol))) | |
2906 (setq rest (memq cell (symbol-value reftex-list-of-labels-symbol))) | |
2907 (setq cell (car (memq (assoc nil rest) rest))) | |
2908 (null (car cell))) | |
2909 (cons (nth 3 cell) (nth 4 cell))) | |
2910 (t nil))))) | |
2911 | |
2912 (defun reftex-toc-pre-command-hook () | |
2913 ;; used as pre command hook in *toc* buffer | |
2914 (reftex-unhighlight 0) | |
2915 (reftex-unhighlight 1)) | |
2916 | |
2917 (defun reftex-toc-post-command-hook () | |
2918 ;; used in the post-command-hook for the *toc* buffer | |
2919 (and (> (point) 1) | |
2920 (save-excursion | |
2921 (reftex-highlight 1 | |
2922 (progn (beginning-of-line) (point)) | |
2923 (progn (end-of-line) (point))))) | |
2924 (cond | |
2925 ((integerp reftex-toc-follow-mode) | |
2926 ;; remove delayed action | |
2927 (setq reftex-toc-follow-mode t)) | |
2928 (reftex-toc-follow-mode | |
2929 ;; show context in other window | |
2930 (condition-case nil | |
2931 (reftex-toc-visit-line) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2932 (error (ding) t))))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2933 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2934 (defun reftex-empty-toc-buffer () |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2935 (if (get-buffer "*toc*") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2936 (save-excursion |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2937 (set-buffer "*toc*") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2938 (setq buffer-read-only nil) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2939 (erase-buffer)))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2940 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2941 (defun reftex-re-enlarge () |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2942 (enlarge-window |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2943 (max 0 (- (or reftex-last-window-height (window-height)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2944 (window-height))))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2945 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2946 (defun reftex-toc-show-help () |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2947 (interactive) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2948 (with-output-to-temp-buffer "*RefTeX Help*" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2949 (princ reftex-toc-help)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2950 ;; If follow mode is active, arrange to delay it one command |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2951 (if reftex-toc-follow-mode |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2952 (setq reftex-toc-follow-mode 1))) |
18050 | 2953 |
2954 (defun reftex-toc-toggle-follow () | |
2955 "Toggle toc-follow mode. | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
2956 (It is not really a mode, just a flag)." |
18050 | 2957 (interactive) |
2958 (setq reftex-toc-follow-mode (not reftex-toc-follow-mode))) | |
2959 (defun reftex-toc-view-line () | |
2960 "View document location in other window." | |
2961 (interactive) | |
2962 (reftex-toc-visit-line)) | |
2963 (defun reftex-toc-goto-line-and-hide () | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
2964 "Go to document location in other window. Hide the *toc* window." |
18050 | 2965 (interactive) |
2966 (reftex-toc-visit-line 'hide)) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2967 (defun reftex-toc-goto-line () |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2968 "Go to document location in other window. Hide the *toc* window." |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2969 (interactive) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2970 (reftex-toc-visit-line t)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2971 (defun reftex-toc-mouse-goto-line-and-hide (ev) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2972 "Go to document location in other window. Hide the *toc* window." |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2973 (interactive "e") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2974 (mouse-set-point ev) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2975 (reftex-toc-visit-line 'hide)) |
18050 | 2976 (defun reftex-toc-quit () |
2977 "Hide the *toc* window and do not move point." | |
2978 (interactive) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2979 (or (one-window-p) (delete-window)) |
18050 | 2980 (switch-to-buffer (marker-buffer reftex-toc-return-marker)) |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2981 (reftex-re-enlarge) |
18050 | 2982 (goto-char (marker-position reftex-toc-return-marker))) |
2983 (defun reftex-toc-quit-and-kill () | |
2984 "Kill the *toc* buffer." | |
2985 (interactive) | |
2986 (kill-buffer "*toc*") | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2987 (or (one-window-p) (delete-window)) |
18050 | 2988 (switch-to-buffer (marker-buffer reftex-toc-return-marker)) |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2989 (reftex-re-enlarge) |
18050 | 2990 (goto-char (marker-position reftex-toc-return-marker))) |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
2991 (defun reftex-toc-redo (&rest ignore) |
18050 | 2992 "Regenerate the *toc* buffer. Call only from within the *toc* buffer" |
2993 (interactive) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2994 (switch-to-buffer-other-window |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
2995 (reftex-get-file-buffer-force reftex-last-toc-file)) |
18050 | 2996 (setq current-prefix-arg '(4)) |
2997 (reftex-toc)) | |
2998 | |
2999 (defun reftex-toc-visit-line (&optional final) | |
3000 ;; Visit the tex file corresponding to the toc entry on the current line. | |
3001 ;; If FINAL is t, stay there | |
3002 ;; If FINAL is 'hide, hide the *toc* window. | |
3003 ;; Otherwise, move cursor back into *toc* window | |
3004 | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3005 (let (file find beg end (toc-window (selected-window)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3006 show-window show-buffer) |
18050 | 3007 (save-excursion |
3008 (beginning-of-line) | |
3009 (setq beg (point)) | |
3010 (end-of-line) | |
3011 (setq end (point))) | |
3012 | |
3013 ;; get the file and the search string | |
3014 (setq file (get-text-property (point) 'file)) | |
3015 (setq find (get-text-property (point) 'find)) | |
3016 (if (or (not file) (not find)) | |
3017 (error "Cannot visit line")) | |
3018 | |
3019 (switch-to-buffer-other-window (reftex-get-file-buffer-force file)) | |
3020 (setq show-window (selected-window)) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3021 (setq show-buffer (current-buffer)) |
18050 | 3022 (goto-char (point-min)) |
3023 | |
3024 (if (not (re-search-forward find nil t)) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3025 (progn |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3026 (select-window toc-window) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3027 (error "Cannot visit line"))) |
18050 | 3028 |
3029 (setq beg (match-beginning 0) | |
3030 end (match-end 0)) | |
3031 | |
3032 (goto-char beg) | |
3033 (recenter 1) | |
3034 (reftex-highlight 0 beg end (current-buffer)) | |
3035 | |
3036 (select-window toc-window) | |
3037 | |
3038 ;; use the `final' parameter to decide what to do next | |
3039 (cond | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3040 ((eq final t) |
18050 | 3041 (reftex-unhighlight 0) |
3042 (select-window show-window)) | |
3043 ((eq final 'hide) | |
3044 (reftex-unhighlight 0) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3045 (or (one-window-p) (delete-window)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3046 (switch-to-buffer show-buffer) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3047 (reftex-re-enlarge)) |
18050 | 3048 (t nil)))) |
3049 | |
3050 ;;; =========================================================================== | |
3051 ;;; | |
3052 ;;; BibTeX citations. | |
3053 | |
3054 ;; Variables and constants | |
3055 | |
18219
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
3056 ;; Define variable to silence compiler warnings |
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
3057 (defvar reftex-found-list) |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3058 (defvar reftex-cite-format-builtin) |
18050 | 3059 |
3060 ;; The history list of regular expressions used for citations | |
3061 (defvar reftex-cite-regexp-hist nil) | |
3062 | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3063 ;; Prompt and help string for citation selection |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3064 (defconst reftex-citation-prompt |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3065 "Select: [n]ext [p]revious [r]estrict [ ]full_entry [q]uit RET [?]Help+more") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3066 |
18050 | 3067 (defconst reftex-citation-help |
3068 "AVAILABLE KEYS IN MAKE CITATION MENU | |
3069 --------------------------------------- | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3070 n / p Go to next/previous entry (Cursor motion works as well). |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3071 C-s / C-r Search forward/backward. Use repeated C-s/C-r as in isearch. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3072 g / r Start over with new regexp / Restrict with additional regexp. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3073 SPC Show full database entry in other window. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3074 f Toggle follow mode: Other window will follow with full db entry. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3075 q Quit without inserting \\cite macro into buffer. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3076 M-r Recursive edit into other window. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3077 RET / a Accept current entry / Accept all entries.") |
18050 | 3078 |
3079 ;; Find bibtex files | |
3080 | |
3081 (defun reftex-get-bibfile-list () | |
3082 ;; Return list of bibfiles for current document | |
3083 | |
3084 ;; Ensure access to scanning info | |
3085 (reftex-access-scan-info) | |
3086 | |
3087 (or (symbol-value reftex-bibfile-list-symbol) | |
3088 (error "No BibTeX files to parse. Add \\bibliography statment to document and reparse."))) | |
3089 | |
3090 (defun reftex-scan-buffer-for-bibliography-statement (bib-list-symbol) | |
3091 ;; Scan buffer for bibliography macro and store file list in bib-list-symbol. | |
3092 (let (file-list dir-list) | |
3093 (setq dir-list | |
3094 (reftex-split | |
3095 (concat path-separator "+") | |
3096 (mapconcat '(lambda(x) | |
3097 (if (getenv x) (getenv x) "")) | |
3098 reftex-bibpath-environment-variables | |
3099 path-separator))) | |
3100 (goto-char (point-min)) | |
3101 (if (re-search-forward "^[ \t]*\\\\bibliography{[ \t]*\\([^}]+\\)" nil t) | |
3102 (progn | |
3103 (setq dir-list | |
3104 (cons (file-name-directory | |
3105 (get-text-property (match-beginning 0) 'file)) | |
3106 dir-list)) | |
3107 (setq file-list | |
3108 (mapcar '(lambda (x) (concat x ".bib")) | |
3109 (reftex-delete-list | |
3110 reftex-bibfile-ignore-list | |
3111 (reftex-split | |
3112 "[ \t\n]*,[ \t\n]*" | |
3113 (reftex-no-props (match-string 1))))))) | |
3114 (message "No \\bibliography command in document.")) | |
3115 (set bib-list-symbol | |
3116 (if file-list | |
3117 (reftex-find-files-on-path file-list dir-list | |
18123 | 3118 "While parsing \\bibliography:") |
18050 | 3119 nil)))) |
3120 | |
3121 (defun reftex-find-files-on-path (file-list path-list &optional error-string) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3122 ;; Search for all files in FILE-LIST on PATH-LIST. Return absolute names. |
18050 | 3123 ;; A missing file throws an exception with the error message ERROR-STRING. |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3124 ;; When error-string is nil, no exception is thrown. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3125 |
18050 | 3126 (let (found-list found file) |
3127 (while file-list | |
3128 (setq file (car file-list) | |
3129 file-list (cdr file-list) | |
3130 found nil) | |
3131 (if (file-name-absolute-p file) | |
3132 (setq found (expand-file-name file)) | |
3133 (let ((dirs path-list)) | |
3134 (while (and dirs (not found)) | |
3135 (if (and (not (string= (car dirs) "")) | |
3136 (file-exists-p (expand-file-name file (car dirs)))) | |
3137 (setq found (expand-file-name file (car dirs)))) | |
3138 (setq dirs (cdr dirs))))) | |
3139 (if (and found | |
3140 (file-exists-p found)) | |
3141 (add-to-list 'found-list (expand-file-name found)) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3142 (and error-string |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3143 (error "%s No such file %s." error-string file)))) |
18050 | 3144 (nreverse found-list))) |
3145 | |
3146 ;; Find a certain reference in any of the BibTeX files. | |
3147 | |
3148 (defun reftex-pop-to-bibtex-entry (key file-list | |
3149 &optional mark-to-kill highlight) | |
3150 ;; Find BibTeX KEY in any file in FILE-LIST in another window. | |
3151 ;; If mark-to-kill is non-nil, mark new buffer to kill." | |
3152 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
3153 (let* ((re (concat "@[a-zA-Z]+[ \t\n\r]*[{(][ \t\n\r]*" (regexp-quote key) "[ \t\n\r,]")) |
18050 | 3154 (window-conf (current-window-configuration)) |
3155 file buf) | |
3156 (catch 'exit | |
3157 (switch-to-buffer-other-window (current-buffer)) | |
3158 (while file-list | |
3159 (setq file (car file-list) | |
3160 file-list (cdr file-list)) | |
3161 (if (not (setq buf (reftex-get-file-buffer-force file mark-to-kill))) | |
3162 (error "No such file %s" file)) | |
3163 (switch-to-buffer buf) | |
3164 (widen) | |
3165 (goto-char 0) | |
3166 (if (re-search-forward re nil t) | |
3167 (progn | |
3168 (goto-char (match-beginning 0)) | |
3169 (recenter 0) | |
3170 (if highlight | |
3171 (reftex-highlight 0 (match-beginning 0) (match-end 0))) | |
3172 (throw 'exit (selected-window))))) | |
3173 (set-window-configuration window-conf) | |
3174 (beep) | |
3175 (message "No BibTeX entry with citation key %s" key)))) | |
3176 | |
3177 ;; Parse bibtex buffers | |
3178 | |
3179 (defun reftex-extract-bib-entries (buffers &optional get-word) | |
3180 ;; Extract bib entries which match regexps from BUFFERS. | |
3181 ;; BUFFERS is a list of buffers or file names. | |
3182 ;; Return list with entries." | |
3183 (let* (re-list first-re rest-re | |
3184 ;; avoid fontification of lookup buffers | |
3185 (lazy-lock-minimum-size 1) | |
3186 (buffer-list (if (listp buffers) buffers (list buffers))) | |
3187 found-list entry buffer1 buffer alist | |
3188 key-point start-point end-point) | |
3189 | |
3190 (setq re-list (reftex-split "[ \t]*&&[ \t]*" | |
3191 (read-string "RegExp [ && RegExp...]: " | |
3192 nil 'reftex-cite-regexp-hist))) | |
3193 | |
3194 (setq first-re (car re-list) ; We'll use the first re to find things, | |
3195 rest-re (cdr re-list)) ; the other to narrow down. | |
3196 (if (string-match "\\`[ \t]*\\'" first-re) | |
3197 (error "Empty regular expression")) | |
3198 | |
3199 (save-excursion | |
3200 (save-window-excursion | |
3201 | |
3202 ;; walk through all bibtex files | |
3203 (while buffer-list | |
3204 (setq buffer (car buffer-list) | |
3205 buffer-list (cdr buffer-list)) | |
3206 (if (and (bufferp buffer) | |
3207 (buffer-live-p buffer)) | |
3208 (setq buffer1 buffer) | |
3209 (setq buffer1 (reftex-get-file-buffer-force | |
3210 buffer (not reftex-keep-temporary-buffers)))) | |
3211 (if (not buffer1) | |
3212 (error "Cannot find BibTeX file %s" buffer) | |
3213 (message "Scanning bibliography database %s" buffer1)) | |
3214 | |
3215 (set-buffer buffer1) | |
3216 (save-excursion | |
3217 (goto-char (point-min)) | |
3218 (while (re-search-forward first-re nil t) | |
3219 (catch 'search-again | |
3220 (setq key-point (point)) | |
3221 (if (not (re-search-backward | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
3222 "^[ \t]*@\\([a-zA-Z]+\\)[ \t\n\r]*[{(]" nil t)) |
18050 | 3223 (throw 'search-again nil)) |
3224 (setq start-point (point)) | |
3225 (goto-char (match-end 0)) | |
3226 (condition-case nil | |
3227 (up-list 1) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3228 (error (goto-char key-point) |
18050 | 3229 (throw 'search-again nil))) |
3230 (setq end-point (point)) | |
3231 | |
3232 ;; Ignore @string, @comment and @c entries or things | |
3233 ;; outside entries | |
3234 (if (or (string= (downcase (match-string 1)) "string") | |
3235 (string= (downcase (match-string 1)) "comment") | |
3236 (string= (downcase (match-string 1)) "c") | |
3237 (< (point) key-point)) ; this means match not in {} | |
3238 (progn | |
3239 (goto-char key-point) | |
3240 (throw 'search-again nil))) | |
3241 | |
3242 ;; Well, we have got a match | |
3243 (setq entry (concat | |
3244 (buffer-substring start-point (point)) "\n")) | |
3245 | |
3246 ;; Check if other regexp match as well | |
3247 (setq re-list rest-re) | |
3248 (while re-list | |
3249 (if (not (string-match (car re-list) entry)) | |
3250 ;; nope - move on | |
3251 (throw 'search-again nil)) | |
3252 (setq re-list (cdr re-list))) | |
3253 | |
3254 (setq alist (reftex-parse-bibtex-entry | |
3255 nil start-point end-point)) | |
3256 (setq alist (cons (cons "&entry" entry) alist)) | |
3257 | |
3258 ;; check for crossref entries | |
3259 (if (assoc "crossref" alist) | |
3260 (setq alist | |
3261 (append | |
3262 alist (reftex-get-crossref-alist alist)))) | |
3263 | |
3264 ;; format the entry | |
3265 (setq alist | |
3266 (cons | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3267 (cons "&formatted" (reftex-format-bib-entry alist)) |
18050 | 3268 alist)) |
3269 | |
3270 ;; add it to the list | |
3271 (setq found-list (cons alist found-list))))) | |
3272 (reftex-kill-temporary-buffers)))) | |
3273 (setq found-list (nreverse found-list)) | |
3274 | |
3275 ;; Sorting | |
3276 (cond | |
3277 ((eq 'author reftex-sort-bibtex-matches) | |
3278 (sort found-list 'reftex-bib-sort-author)) | |
3279 ((eq 'year reftex-sort-bibtex-matches) | |
3280 (sort found-list 'reftex-bib-sort-year)) | |
3281 ((eq 'reverse-year reftex-sort-bibtex-matches) | |
3282 (sort found-list 'reftex-bib-sort-year-reverse)) | |
3283 (t found-list)))) | |
3284 | |
3285 (defun reftex-bib-sort-author (e1 e2) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3286 (let ((al1 (reftex-get-bib-names "author" e1)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3287 (al2 (reftex-get-bib-names "author" e2))) |
18050 | 3288 (while (and al1 al2 (string= (car al1) (car al2))) |
3289 (setq al1 (cdr al1) | |
3290 al2 (cdr al2))) | |
3291 (if (and (stringp (car al1)) | |
3292 (stringp (car al2))) | |
3293 (string< (car al1) (car al2)) | |
3294 (not (stringp (car al1)))))) | |
3295 | |
3296 (defun reftex-bib-sort-year (e1 e2) | |
3297 (< (string-to-int (cdr (assoc "year" e1))) | |
3298 (string-to-int (cdr (assoc "year" e2))))) | |
3299 | |
3300 (defun reftex-bib-sort-year-reverse (e1 e2) | |
3301 (> (string-to-int (or (cdr (assoc "year" e1)) "0")) | |
3302 (string-to-int (or (cdr (assoc "year" e2)) "0")))) | |
3303 | |
3304 (defun reftex-get-crossref-alist (entry) | |
3305 ;; return the alist from a crossref entry | |
3306 (let ((crkey (cdr (assoc "crossref" entry))) | |
3307 start) | |
3308 (save-excursion | |
3309 (save-restriction | |
3310 (widen) | |
3311 (if (re-search-forward | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
3312 (concat "@\\w+[{(][ \t\n\r]*" (regexp-quote crkey) "[ \t\n\r]*,") nil t) |
18050 | 3313 (progn |
3314 (setq start (match-beginning 0)) | |
3315 (condition-case nil | |
3316 (up-list 1) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3317 (error nil)) |
18050 | 3318 (reftex-parse-bibtex-entry nil start (point))) |
3319 nil))))) | |
3320 | |
3321 ;; Parse and format individual entries | |
3322 | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3323 (defun reftex-get-bib-names (field entry) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3324 ;; Return a list with the author or editor anmes in ENTRY |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3325 (let ((names (reftex-get-bib-field field entry))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3326 (if (equal "" names) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3327 (setq names (reftex-get-bib-field "editor" entry))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3328 (while (string-match "\\band\\b[ \t]*" names) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3329 (setq names (replace-match "\n" nil t names))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3330 (while (string-match "[\\.a-zA-Z\\-]+\\.[ \t]*\\|,.*\\|[{}]+" names) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3331 (setq names (replace-match "" nil t names))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3332 (while (string-match "^[ \t]+\\|[ \t]+$" names) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3333 (setq names (replace-match "" nil t names))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3334 (while (string-match "[ \t][ \t]+" names) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3335 (setq names (replace-match " " nil t names))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3336 (reftex-split "\n" names))) |
18050 | 3337 |
3338 (defun reftex-parse-bibtex-entry (entry &optional from to) | |
3339 (let (alist key start field) | |
3340 (save-excursion | |
3341 (save-restriction | |
3342 (if entry | |
3343 (progn | |
3344 (switch-to-buffer "*RefTeX-scratch*") | |
3345 (fundamental-mode) | |
3346 (erase-buffer) | |
3347 (insert entry)) | |
3348 (widen) | |
3349 (narrow-to-region from to)) | |
3350 (goto-char (point-min)) | |
3351 | |
3352 (if (re-search-forward | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
3353 "@\\(\\w+\\)[ \t\n\r]*[{(][ \t\n\r]*\\([^ \t\n\r,]+\\)" nil t) |
18050 | 3354 (setq alist |
3355 (list | |
3356 (cons "&type" (downcase (reftex-no-props (match-string 1)))) | |
3357 (cons "&key" (reftex-no-props (match-string 2)))))) | |
3358 (while (re-search-forward "\\(\\w+\\)[ \t\n\r]*=[ \t\n\r]*" nil t) | |
3359 (setq key (reftex-no-props (downcase (match-string 1)))) | |
3360 (cond | |
3361 ((= (following-char) ?{) | |
3362 (forward-char 1) | |
3363 (setq start (point)) | |
3364 (condition-case nil | |
3365 (up-list 1) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3366 (error nil))) |
18050 | 3367 ((= (following-char) ?\") |
3368 (forward-char 1) | |
3369 (setq start (point)) | |
3370 (while (and (search-forward "\"" nil t) | |
3371 (= ?\\ (char-after (- (point) 2)))))) | |
3372 (t | |
3373 (setq start (point)) | |
3374 (re-search-forward "[ \t\n\r,}]" nil 1))) | |
3375 (setq field (buffer-substring-no-properties start (1- (point)))) | |
3376 ;; remove extra whitesp | |
3377 (while (string-match "[\n\t\r]\\|[ \t][ \t]+" field) | |
3378 (setq field (replace-match " " nil t field))) | |
3379 ;; remove leading garbage | |
3380 (if (string-match "^[ \t{]+" field) | |
3381 (setq field (replace-match "" nil t field))) | |
3382 ;; remove trailing garbage | |
3383 (if (string-match "[ \t}]+$" field) | |
3384 (setq field (replace-match "" nil t field))) | |
3385 (setq alist (cons (cons key field) alist))) | |
3386 alist)))) | |
3387 | |
3388 (defun reftex-get-bib-field (fieldname entry) | |
3389 ;; Extract the field FIELDNAME from an ENTRY | |
3390 (or (cdr (assoc fieldname entry)) | |
3391 "")) | |
3392 | |
3393 (defun reftex-format-bib-entry (entry) | |
3394 ;; Format a BibTeX ENTRY so that it is nice to look at | |
3395 (let* | |
3396 ((rtn nil) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3397 (auth-list (reftex-get-bib-names "author" entry)) |
18050 | 3398 (authors (mapconcat '(lambda (x) x) auth-list ", ")) |
3399 (year (reftex-get-bib-field "year" entry)) | |
3400 (title (reftex-get-bib-field "title" entry)) | |
3401 (type (reftex-get-bib-field "&type" entry)) | |
3402 (key (reftex-get-bib-field "&key" entry)) | |
3403 (extra | |
3404 (cond | |
3405 ((equal type "article") | |
3406 (concat (reftex-get-bib-field "journal" entry) " " | |
3407 (reftex-get-bib-field "volume" entry) ", " | |
3408 (reftex-get-bib-field "pages" entry))) | |
3409 ((equal type "book") | |
3410 (concat "book (" (reftex-get-bib-field "publisher" entry) ")")) | |
3411 ((equal type "phdthesis") | |
3412 (concat "PhD: " (reftex-get-bib-field "school" entry))) | |
3413 ((equal type "mastersthesis") | |
3414 (concat "Master: " (reftex-get-bib-field "school" entry))) | |
3415 ((equal type "inbook") | |
3416 (concat "Chap: " (reftex-get-bib-field "chapter" entry) | |
3417 ", pp. " (reftex-get-bib-field "pages" entry))) | |
3418 ((or (equal type "conference") | |
3419 (equal type "incollection") | |
3420 (equal type "inproceedings")) | |
3421 (concat "in: " (reftex-get-bib-field "booktitle" entry))) | |
3422 (t "")))) | |
3423 (setq authors | |
3424 (if (> (length authors) 30) | |
3425 (concat (substring authors 0 27) "...") | |
3426 (format "%-30s" authors)) | |
3427 title | |
3428 (if (> (length title) 70) | |
3429 (concat (substring title 0 67) "...") | |
3430 (format "%-70s" title)) | |
3431 extra | |
3432 (if (> (length extra) 40) | |
3433 (concat (substring extra 0 37) "...") | |
3434 (format "%-40s" extra))) | |
3435 (if (reftex-use-fonts) | |
3436 (progn | |
3437 (put-text-property 0 (length authors) 'face 'font-lock-keyword-face | |
3438 authors) | |
3439 (put-text-property 0 (length title) 'face 'font-lock-comment-face | |
3440 title) | |
3441 (put-text-property 0 (length extra) 'face 'font-lock-reference-face | |
3442 extra))) | |
3443 (setq rtn (concat key "\n " authors " " year " " extra | |
3444 "\n " title "\n\n")) | |
3445 rtn)) | |
3446 | |
3447 ;; Make a citation | |
3448 | |
3449 (defun reftex-citation (&optional arg no-insert) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
3450 "Make a citation using BibTeX database files. |
18050 | 3451 After asking for a Regular Expression, it scans the buffers with |
3452 bibtex entries (taken from the \\bibliography command) and offers the | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
3453 matching entries for selection. The selected entry is formated according |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
3454 to `reftex-cite-format' and inserted into the buffer. |
18050 | 3455 If NO-INSERT is non-nil, nothing is inserted, only the selected key returned. |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
3456 The regular expression uses an expanded syntax: && is interpreted as `and'. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
3457 Thus, `aaaa&&bbb' matches entries which contain both `aaaa' and `bbb'. |
18123 | 3458 When this function is called with point inside the braces of a \\cite |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
3459 command, it will add another key, ignoring the value of `reftex-cite-format'. |
18050 | 3460 When called with a numeric prefix, that many citations will be made and all |
18123 | 3461 put into the same \\cite command. |
18050 | 3462 When called with just C-u as prefix, enforces rescan of buffer for |
3463 bibliography statement (e.g. if it was changed)." | |
3464 | |
3465 (interactive "P") | |
3466 | |
3467 ;; check for recursive edit | |
3468 (reftex-check-recursive-edit) | |
3469 | |
3470 ;; if there is just 1 C-u prefix arg, force to rescan buffer | |
3471 (if (and current-prefix-arg | |
3472 (listp current-prefix-arg) | |
3473 (= 4 (prefix-numeric-value arg))) | |
3474 (reftex-reset-scanning-information)) | |
3475 | |
3476 ;; check if there is already a cite command at point and change cite format | |
3477 ;; in order to only add another reference in the same cite command. | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3478 (let (key format (macro (car (car (reftex-what-macro t))))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3479 (if (and (stringp macro) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3480 (string-match "\\`\\\\cite\\|cite\\'" macro)) |
18050 | 3481 (progn |
3482 (cond | |
3483 ((or (not arg) | |
3484 (not (listp arg))) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3485 (setq format |
18050 | 3486 (concat |
3487 (if (not (or (= (preceding-char) ?{) | |
3488 (= (preceding-char) ?,))) | |
3489 "," | |
3490 "") | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3491 "%l" |
18050 | 3492 (if (not (or (= (following-char) ?}) |
3493 (= (following-char) ?,))) | |
3494 "," | |
3495 "")))) | |
3496 (t | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3497 (setq format "%l")))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3498 ;; else: figure out the correct format |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3499 (setq format |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3500 (cond |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3501 ((stringp reftex-cite-format) reftex-cite-format) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3502 ((and (symbolp reftex-cite-format) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3503 (assq reftex-cite-format reftex-cite-format-builtin)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3504 (nth 2 (assq reftex-cite-format reftex-cite-format-builtin))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3505 (t reftex-cite-format))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3506 (if (listp format) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3507 (save-window-excursion |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3508 (with-output-to-temp-buffer "*RefTeX Select*" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3509 (princ "SELECT A CITATION FORMAT\n\n") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3510 (princ |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3511 (mapconcat |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3512 (function (lambda (x) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3513 (format "[%c] %s %s" (car x) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3514 (if (> (car x) 31) " " "") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3515 (cdr x)))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3516 format "\n"))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3517 (setq key (read-char)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3518 (if (assq key format) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3519 (setq format (cdr (assq key format))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3520 (error "No citation format associated with key `%c'" key))))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3521 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3522 (let* (entry cnt rtn ins-string re-list re |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3523 ;; scan bibtex files |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3524 (lazy-lock-minimum-size 1) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3525 (reftex-found-list (reftex-extract-bib-entries |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3526 (reftex-get-bibfile-list))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3527 (found-list-r nil)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3528 (if (not reftex-found-list) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3529 (error "Sorry, no matches found")) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3530 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3531 ;; remember where we came from |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3532 (setq reftex-call-back-to-this-buffer (current-buffer)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3533 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3534 ;; offer selection |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3535 (save-window-excursion |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3536 (switch-to-buffer-other-window "*RefTeX Select*") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3537 (erase-buffer) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3538 (reftex-insert-bib-matches reftex-found-list) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3539 (if (= 0 (buffer-size)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3540 (error "Sorry, no matches found")) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3541 (setq truncate-lines t) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3542 (goto-char 1) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3543 (if (catch 'exit |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3544 (while t |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3545 (setq rtn |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3546 (reftex-select-item |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3547 reftex-citation-prompt |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3548 "^[^ \t\n]" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3549 4 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3550 reftex-citation-help |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3551 '(?r ?a ?g ?\C-m) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3552 nil |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3553 'reftex-bibtex-selection-callback nil)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3554 (setq key (car rtn) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3555 cnt (nth 1 rtn)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3556 (if (not key) (throw 'exit nil)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3557 (cond |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3558 ((eq key ?g) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3559 (setq reftex-found-list |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3560 (save-excursion |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3561 (set-buffer reftex-call-back-to-this-buffer) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3562 (reftex-extract-bib-entries |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3563 (reftex-get-bibfile-list)))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3564 (erase-buffer) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3565 (reftex-insert-bib-matches reftex-found-list) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3566 (if (= 0 (buffer-size)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3567 (error "Sorry, no matches found")) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3568 (goto-char 1)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3569 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3570 ((eq key ?r) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3571 ;; restrict with new regular expression |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3572 (setq re-list |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3573 (reftex-split "[ \t]*&&[ \t]*" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3574 (read-string |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3575 "RegExp [ && RegExp...]: " |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3576 nil 'reftex-cite-regexp-hist))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3577 (while re-list |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3578 (setq re (car re-list) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3579 re-list (cdr re-list)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3580 (setq found-list-r |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3581 (delete "" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3582 (mapcar |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3583 '(lambda (x) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3584 (if (string-match |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3585 re (cdr (assoc "&entry" x))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3586 x |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3587 "")) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3588 reftex-found-list)))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3589 (if found-list-r |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3590 (setq reftex-found-list found-list-r) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3591 (ding)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3592 (erase-buffer) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3593 (reftex-insert-bib-matches reftex-found-list) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3594 (goto-char 1)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3595 ((eq key ?a) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3596 (setq entry 'all) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3597 (throw 'exit t)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3598 ((or (eq key ?\C-m) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3599 (eq key 'return)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3600 (if cnt |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3601 (setq entry (nth cnt reftex-found-list)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3602 (setq entry nil)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3603 (throw 'exit t)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3604 (t |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3605 (ding))))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3606 (progn |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3607 ;; format the entry |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3608 (if (eq entry 'all) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3609 (setq ins-string |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3610 (mapconcat |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3611 '(lambda (entry) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3612 (reftex-format-citation entry format)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3613 reftex-found-list "\n")) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3614 (setq ins-string (reftex-format-citation entry format)))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3615 (setq ins-string "") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3616 (message "Quit"))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3617 (kill-buffer "*RefTeX Select*") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3618 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3619 (if (not no-insert) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3620 (progn |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3621 (insert ins-string) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3622 (if (string-match "\\?" ins-string) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3623 (progn |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3624 (search-backward "?") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3625 (delete-char 1))))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3626 (message "") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3627 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3628 ;; Check if the prefix arg was numeric, and call recursively |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3629 (if (and (integerp arg) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3630 (> arg 1) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3631 (re-search-backward |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3632 "\\\\\\([a-zA-Z]*cite\\|cite[a-zA-Z]*\\)\\**\\(\\[[^]]*\\]\\)*{\\([^}]*\\)" nil t)) ;;; FIXME this can break with ? in format |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3633 (progn |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3634 (goto-char (match-end 0)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3635 (setq arg (1- arg)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3636 (reftex-citation arg)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3637 (reftex-kill-temporary-buffers)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3638 ;; Return the citation key |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3639 (or (eq entry 'all) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3640 (reftex-get-bib-field "&key" entry))))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3641 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3642 (defun reftex-insert-bib-matches (list) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3643 ;; Insert the bib matches and number them correctly |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3644 (let ((cnt -1) tmp) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3645 (mapcar '(lambda (x) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3646 (setq tmp (cdr (assoc "&formatted" x)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3647 cnt (1+ cnt)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3648 (put-text-property 0 (length tmp) 'cnt cnt tmp) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3649 (insert tmp)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3650 list))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3651 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3652 (defun reftex-format-names (namelist n) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3653 (interactive) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3654 (let (last (len (length namelist))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3655 (cond |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3656 ((= 1 len) (car namelist)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3657 ((> len n) (concat (car namelist) (nth 2 reftex-cite-punctuation))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3658 (t |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3659 (setq n (min len n) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3660 last (nth (1- n) namelist)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3661 (setcdr (nthcdr (- n 2) namelist) nil) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3662 (concat |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3663 (mapconcat 'identity namelist (nth 0 reftex-cite-punctuation)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3664 (nth 1 reftex-cite-punctuation) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3665 last))))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3666 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3667 (defun reftex-format-citation (entry format) |
18050 | 3668 ;; Format a citation from the info in the BibTeX ENTRY |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3669 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3670 (if (not (stringp format)) (setq format "\\cite{%l}")) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3671 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3672 (if (and reftex-comment-citations |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3673 (string-match "%l" reftex-cite-comment-format)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3674 (error "reftex-cite-comment-format contains illeagal %%l")) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3675 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3676 (while (string-match |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3677 "\\(\\`\\|[^%]\\)\\(\\(%\\([0-9]*\\)\\([a-zA-Z]\\)\\)[.,;: ]*\\)" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3678 format) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3679 (let ((n (string-to-int (match-string 4 format))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3680 (l (string-to-char (match-string 5 format))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3681 rpl b e) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3682 (save-match-data |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3683 (setq rpl |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3684 (cond |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3685 ((= l ?l) (concat |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3686 (reftex-get-bib-field "&key" entry) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3687 (if reftex-comment-citations |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3688 reftex-cite-comment-format |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3689 ""))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3690 ((= l ?a) (reftex-format-names |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3691 (reftex-get-bib-names "author" entry) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3692 (or n 2))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3693 ((= l ?A) (car (reftex-get-bib-names "author" entry))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3694 ((= l ?b) (reftex-get-bib-field "booktitle" entry)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3695 ((= l ?c) (reftex-get-bib-field "chapter" entry)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3696 ((= l ?d) (reftex-get-bib-field "edition" entry)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3697 ((= l ?e) (reftex-format-names |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3698 (reftex-get-bib-names "editor" entry) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3699 (or n 2))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3700 ((= l ?E) (car (reftex-get-bib-names "editor" entry))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3701 ((= l ?h) (reftex-get-bib-field "howpublished" entry)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3702 ((= l ?i) (reftex-get-bib-field "institution" entry)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3703 ((= l ?j) (reftex-get-bib-field "journal" entry)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3704 ((= l ?k) (reftex-get-bib-field "key" entry)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3705 ((= l ?m) (reftex-get-bib-field "month" entry)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3706 ((= l ?n) (reftex-get-bib-field "number" entry)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3707 ((= l ?o) (reftex-get-bib-field "organization" entry)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3708 ((= l ?p) (reftex-get-bib-field "pages" entry)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3709 ((= l ?P) (car (reftex-split |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3710 "[- .]+" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3711 (reftex-get-bib-field "pages" entry)))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3712 ((= l ?s) (reftex-get-bib-field "school" entry)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3713 ((= l ?u) (reftex-get-bib-field "publisher" entry)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3714 ((= l ?r) (reftex-get-bib-field "address" entry)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3715 ((= l ?t) (reftex-get-bib-field "title" entry)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3716 ((= l ?v) (reftex-get-bib-field "volume" entry)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3717 ((= l ?y) (reftex-get-bib-field "year" entry))))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3718 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3719 (if (string= rpl "") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3720 (setq b (match-beginning 2) e (match-end 2)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3721 (setq b (match-beginning 3) e (match-end 3))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3722 (setq format (concat (substring format 0 b) rpl (substring format e))))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3723 (while (string-match "%%" format) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3724 (setq format (replace-match "%" t t format))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3725 (while (string-match "[ ,.;:]*%<" format) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3726 (setq format (replace-match "" t t format))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3727 format) |
18050 | 3728 |
3729 ;; this is slow and not recommended for follow mode | |
3730 (defun reftex-bibtex-selection-callback (cnt) | |
3731 ;; Callback function to be called from the BibTeX selection, in | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
3732 ;; order to display context. This function is relatively slow and not |
18050 | 3733 ;; recommended for follow mode, just for individual lookups. |
3734 (let ((win (selected-window)) | |
18219
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
3735 (key (reftex-get-bib-field "&key" (nth cnt reftex-found-list))) |
18050 | 3736 (bibfile-list (save-excursion |
3737 (set-buffer reftex-call-back-to-this-buffer) | |
3738 (reftex-get-bibfile-list)))) | |
3739 (reftex-pop-to-bibtex-entry key bibfile-list | |
3740 (not reftex-keep-temporary-buffers) t) | |
3741 (select-window win))) | |
3742 | |
3743 ;;; =========================================================================== | |
3744 ;;; | |
3745 ;;; Here is the routine used for selection | |
3746 | |
3747 ;; Marker for return point from recursive edit | |
3748 (defvar reftex-recursive-edit-marker (make-marker)) | |
3749 | |
3750 (defun reftex-check-recursive-edit () | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
3751 ;; Check if we are already in a recursive edit. Abort with helpful |
18050 | 3752 ;; message if so. |
3753 (if (marker-position reftex-recursive-edit-marker) | |
3754 (error | |
3755 (substitute-command-keys | |
3756 "In unfinished recursive edit. Finish (\\[exit-recursive-edit]) or abort (\\[abort-recursive-edit]).")))) | |
3757 | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3758 (defun reftex-select-item (prompt next-re size help-string |
18050 | 3759 event-list &optional offset |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3760 call-back cb-flag match-everywhere) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3761 ;; Select an item. Show PROMPT to user, find next item with NEXT-RE |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3762 ;; regular expression, return on any of the events listed in |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3763 ;; EVENT-LIST. The function returns the event along with an integer |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3764 ;; indicating which item was selected. When OFFSET is specified, |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3765 ;; starts at that item in the list. When CALL-BACK is given, it is a |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3766 ;; function which is called with the index of the element. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3767 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3768 (let* (key key-sq b e ev cnt last-cnt cmd skip-callback |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3769 (search-str "") tmp search-start matched forward mini-map last-key |
18050 | 3770 (offset1 (or offset 1))) |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3771 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3772 ;; Set up a minibuffer keymap for the search stuff |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3773 (setq mini-map (copy-keymap minibuffer-local-map)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3774 (define-key mini-map "\C-s" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3775 '(lambda () (interactive) (setq forward t) (exit-minibuffer))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3776 (define-key mini-map "\C-r" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3777 '(lambda () (interactive) (setq forward nil) (exit-minibuffer))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3778 (define-key mini-map "\C-m" 'exit-minibuffer) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3779 |
18050 | 3780 (setq ev |
3781 (catch 'exit | |
3782 (save-window-excursion | |
3783 (if (= 0 (buffer-size)) | |
3784 (throw 'exit nil)) | |
3785 (setq truncate-lines t) | |
3786 (goto-char 1) | |
3787 (if (not (re-search-forward next-re nil t offset1)) | |
3788 (progn ; in case the offset is illegal | |
3789 (setq offset1 1) | |
3790 (if (not (re-search-forward next-re nil t offset1)) | |
3791 (throw 'exit nil)))) | |
3792 (beginning-of-line 1) | |
3793 (while t | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3794 (setq last-cnt (or cnt last-cnt)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3795 (setq cnt (get-text-property (point) 'cnt)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3796 (if (and cnt cb-flag call-back (not skip-callback)) |
18050 | 3797 (funcall call-back cnt)) |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3798 (setq skip-callback nil) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3799 (if cnt |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3800 (setq b (or (previous-single-property-change |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3801 (1+ (point)) 'cnt) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3802 (point-min)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3803 e (or (next-single-property-change |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3804 (point) 'cnt) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3805 (point-max))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3806 (setq b (point) e (point))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3807 (reftex-highlight 1 b e) |
18050 | 3808 (if (or (not (pos-visible-in-window-p b)) |
3809 (not (pos-visible-in-window-p e))) | |
3810 (recenter (/ (window-height) 2))) | |
3811 (setq key-sq (read-key-sequence prompt)) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3812 (setq last-key key) |
18050 | 3813 (setq key (car |
3814 (cond | |
3815 ((fboundp 'listify-key-sequence) ; Emacs | |
3816 (listify-key-sequence key-sq)) | |
3817 ((fboundp 'event-to-character) ; XEmacs | |
3818 (mapcar 'event-to-character key-sq)) | |
3819 (t (error "Please report this problem to dominik@strw.leidenuniv.nl"))))) | |
3820 | |
3821 (setq cmd (key-binding key-sq)) | |
3822 | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3823 (reftex-unhighlight 2) |
18050 | 3824 (reftex-unhighlight 0) |
3825 | |
3826 (cond | |
3827 | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3828 ;; Single line motions |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3829 ((or (eq key ?n) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3830 (eq key ?\C-i) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3831 (eq cmd 'next-line)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3832 (forward-char 1) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3833 (re-search-forward next-re nil t 1) |
18050 | 3834 (beginning-of-line 1)) |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3835 ((or (eq key ?p) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3836 (eq cmd 'previous-line)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3837 (re-search-backward next-re nil t)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3838 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3839 ;; Page motions |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3840 ((eq cmd 'scroll-up) |
18050 | 3841 (while (and (pos-visible-in-window-p) |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3842 (re-search-forward next-re nil t))) |
18050 | 3843 (beginning-of-line 1) |
3844 (recenter 1)) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3845 ((eq cmd 'scroll-down) |
18050 | 3846 (while (and (pos-visible-in-window-p) |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3847 (re-search-backward next-re nil t))) |
18050 | 3848 (recenter (- (window-height) size 2))) |
3849 | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3850 ;; Begin and end of buffer |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3851 ((eq cmd 'beginning-of-buffer) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3852 (goto-char (point-min)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3853 (re-search-forward next-re nil t) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3854 (beginning-of-line 1)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3855 ((eq cmd 'end-of-buffer) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3856 (goto-char (point-max)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3857 (re-search-backward next-re nil t)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3858 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3859 ;; Exit |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3860 ((eq key ?q) |
18050 | 3861 (throw 'exit nil)) |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3862 ((eq key ?\C-g) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3863 (if (or (eq last-key ?\C-s) (eq last-key ?\C-r)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3864 (ding) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3865 (bury-buffer) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3866 (error "Abort"))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3867 ((or (eq key ?\C-m) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3868 (eq key 'return) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3869 (eq cmd 'newline)) |
18050 | 3870 (throw 'exit 'return)) |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3871 ((memq key event-list) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3872 (throw 'exit key)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3873 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3874 ;; Callback |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3875 ((or (eq key ?C) ; backward compatibility |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3876 (eq key ?f)) |
18050 | 3877 (setq cb-flag (not cb-flag))) |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3878 ((eq key ?\ ) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3879 (if cnt (funcall call-back cnt) (ding))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3880 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3881 ;; Help |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3882 ((eq key ?\?) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3883 (with-output-to-temp-buffer "*RefTeX Help*" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3884 (princ help-string)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3885 (setq skip-callback t)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3886 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3887 ;; Searching |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3888 ((or (setq forward (eq key ?\C-s)) (eq key ?\C-r)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3889 (if (or (and (not (eq last-key ?\C-s)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3890 (not (eq last-key ?\C-r))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3891 (string= search-str "")) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3892 (setq tmp ; get a new string |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3893 (read-from-minibuffer |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3894 (if (string= search-str "") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3895 "Search: " |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3896 (format "Search [%s]:" search-str)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3897 nil mini-map) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3898 search-str (if (string= tmp "") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3899 search-str tmp))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3900 (setq search-start (point)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3901 (and (not (string= search-str "")) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3902 (progn |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3903 (while |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3904 (and (setq matched |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3905 (if forward |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3906 (search-forward search-str nil 1) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3907 (search-backward search-str nil 1))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3908 (or (>= (save-excursion |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3909 (goto-char (match-beginning 0)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3910 (current-column)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3911 (window-width)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3912 (not (or (get-text-property (point) 'cnt) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3913 match-everywhere))))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3914 (if matched |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3915 (reftex-highlight 2 (match-beginning 0) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3916 (match-end 0)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3917 (ding) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3918 (goto-char search-start))))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3919 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3920 ;; Recursive edit |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3921 ((eq key ?\M-r) |
18050 | 3922 (set-marker reftex-recursive-edit-marker (point)) |
3923 (unwind-protect | |
3924 (progn | |
3925 (save-window-excursion | |
3926 (save-excursion | |
3927 (other-window 1) | |
3928 (message | |
3929 (substitute-command-keys | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
3930 "Recursive edit. Return to selection with \\[exit-recursive-edit]")) |
18050 | 3931 (recursive-edit))) |
3932 (if (not (equal (marker-buffer | |
3933 reftex-recursive-edit-marker) | |
3934 (current-buffer))) | |
3935 (error | |
3936 "Cannot continue RefTeX from this buffer.")) | |
3937 (goto-char reftex-recursive-edit-marker)) | |
3938 (set-marker reftex-recursive-edit-marker nil))) | |
3939 | |
3940 (t | |
3941 (ding))))))) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3942 (and (get-buffer "*RefTeX Help*") (kill-buffer "*RefTeX Help*")) |
18050 | 3943 (message "") |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3944 (list ev cnt last-cnt))) |
18050 | 3945 |
3946 ;;; =========================================================================== | |
3947 ;;; | |
3948 ;;; View cross references | |
3949 | |
3950 (defun reftex-view-crossref (&optional arg) | |
18123 | 3951 "View cross reference of \\ref or \\cite macro at point. |
3952 If the macro at point is a \\ref, show the corresponding label definition. | |
3953 If it is a \\cite, show the BibTeX database entry. | |
18050 | 3954 If there is no such macro at point, search forward to find one. |
3955 When you call this function several times in direct successtion, point will | |
3956 move to view subsequent cross references further down in the buffer. | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3957 To cope with the plethora of variations in packages, this function |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3958 assumes any macro either starting with ending in `ref' or `cite' to contain |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3959 cross references. |
18050 | 3960 With argument, actually select the window showing the cross reference." |
3961 | |
3962 (interactive "P") | |
3963 | |
3964 ;; See where we are. | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3965 (let* ((re "\\\\\\([a-z]*\\(cite\\|ref\\)\\|\\(cite\\|ref\\)[a-z]*\\)\\**\\(\\[[^{}]*\\]\\)?{") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3966 (macro (car (car (reftex-what-macro t)))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3967 (this-word (reftex-this-word "*a-zA-Z\\\\")) |
18050 | 3968 (my-window (get-buffer-window (current-buffer))) |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3969 pop-window cmd args label point) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3970 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3971 (if (and macro |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3972 (string-match "\\`\\\\cite\\|\\`\\\\ref\\|cite\\'\\|ref\\'" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3973 macro)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3974 (and (setq macro (match-string 0 macro)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3975 (string-match "\\`\\\\" macro) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3976 (setq macro (substring macro 1))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3977 (setq macro nil)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3978 |
18050 | 3979 (if (and macro (eq last-command this-command)) |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3980 (if (string= macro "cite") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3981 (progn |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3982 (skip-chars-forward "^},%") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3983 (while (and (eq (following-char) ?%) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3984 (or (beginning-of-line 2) t) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3985 (skip-chars-forward " \t\n"))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3986 (skip-chars-forward ",") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3987 (if (eq (following-char) ?}) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3988 (setq macro nil))) |
18050 | 3989 (setq macro nil))) |
3990 | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3991 (if (and (not macro) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3992 (eq this-command 'reftex-view-crossref) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3993 (or (not (string-match "\\`\\\\" this-word)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3994 (search-backward "\\" nil t) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3995 t) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3996 (re-search-forward re nil t)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3997 (setq macro (or (match-string 2) (match-string 3)))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
3998 |
18050 | 3999 (if (not macro) |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4000 (error "No cross reference to display")) |
18050 | 4001 |
4002 ;; Ensure access to scanning info | |
4003 (reftex-access-scan-info) | |
4004 | |
4005 (cond | |
4006 ((string= macro "cite") | |
4007 (setq cmd 'reftex-pop-to-bibtex-entry | |
4008 args (list | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4009 (reftex-no-props (reftex-this-word "^{},%\n")) |
18050 | 4010 (reftex-get-bibfile-list) nil t))) |
4011 ((string= macro "ref") | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4012 (let* ((label (reftex-no-props (reftex-this-word "^{}%\n"))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4013 (entry (assoc label (symbol-value reftex-list-of-labels-symbol)))) |
18050 | 4014 (if entry |
4015 (setq cmd 'reftex-pop-to-label | |
4016 args (list label (list (nth 3 entry)) nil t)) | |
4017 (error "Label %s not known - reparse document might help" label)))) | |
4018 (t (error "This should not happen"))) | |
4019 (setq point (point)) | |
4020 (apply cmd args) | |
4021 (setq pop-window (selected-window)) | |
4022 (add-hook 'pre-command-hook 'reftex-highlight-shall-die) | |
4023 (select-window my-window) | |
4024 (goto-char point) | |
4025 (and arg (select-window pop-window)))) | |
4026 | |
4027 (defun reftex-mouse-view-crossref (ev) | |
18123 | 4028 "View cross reference of \\ref or \\cite macro where you click. |
4029 If the macro at point is a \\ref, show the corresponding label definition. | |
4030 If it is a \\cite, show the BibTeX database entry. | |
18050 | 4031 If there is no such macro at point, search forward to find one. |
4032 With argument, actually select the window showing the cross reference." | |
4033 (interactive "e") | |
4034 (mouse-set-point ev) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4035 (setq last-command 'self-insert-command) ;; make sure we do not move! |
18050 | 4036 (reftex-view-crossref current-prefix-arg)) |
4037 | |
4038 ;;; =========================================================================== | |
4039 ;;; | |
4040 ;;; Functions that check out the surroundings | |
4041 | |
4042 (defun reftex-what-macro (which &optional bound) | |
4043 ;; Find out if point is within the arguments of any TeX-macro. | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
4044 ;; The return value is either ("\\macro" . (point)) or a list of them. |
18050 | 4045 |
4046 ;; If WHICH is nil, immediately return nil. | |
4047 ;; If WHICH is t, return list of all macros enclosing point. | |
4048 ;; If WHICH is a list of macros, look only for those macros and return the | |
4049 ;; name of the first macro in this list found to enclose point. | |
4050 ;; If the optional BOUND is an integer, bound backwards directed | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
4051 ;; searches to this point. If it is nil, limit to nearest \section - |
18050 | 4052 ;; like statement. |
4053 | |
4054 ;; This function is pretty stable, but can be fooled if the text contains | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
4055 ;; things like \macro{aa}{bb} where \macro is defined to take only one |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
4056 ;; argument. As RefTeX cannot know this, the string "bb" would still be |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
4057 ;; considered an argument of macro \macro. |
18050 | 4058 |
4059 (catch 'exit | |
4060 (if (null which) (throw 'exit nil)) | |
4061 (let ((bound (or bound (save-excursion (re-search-backward | |
4062 reftex-section-regexp nil 1) | |
4063 (point)))) | |
4064 pos cmd-list cmd) | |
4065 (save-restriction | |
4066 (save-excursion | |
4067 (narrow-to-region (max 1 bound) (point-max)) | |
4068 ;; move back out of the current parenthesis | |
4069 (while (condition-case nil | |
4070 (progn (up-list -1) t) | |
4071 (error nil)) | |
4072 ;; move back over any touching sexps | |
4073 (while (or (= (preceding-char) ?\]) | |
4074 (= (preceding-char) ?\})) | |
4075 (backward-sexp)) | |
4076 (setq pos (point)) | |
4077 (if (and (or (= (following-char) ?\[) | |
4078 (= (following-char) ?\{)) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4079 (and (re-search-backward "\\(\\\\[*a-zA-Z]+\\)" nil t) |
18050 | 4080 (= (match-end 0) pos))) |
4081 (progn | |
4082 (setq cmd (buffer-substring-no-properties | |
4083 (match-beginning 0) (match-end 0))) | |
4084 (if (eq t which) | |
4085 (setq cmd-list (cons (cons cmd (point)) cmd-list)) | |
4086 (if (member cmd which) | |
4087 (throw 'exit (cons cmd (point))))))) | |
4088 (goto-char pos))) | |
4089 (nreverse cmd-list))))) | |
4090 | |
4091 (defun reftex-what-environment (which &optional bound) | |
4092 ;; Find out if point is inside a LaTeX environment. | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
4093 ;; The return value is (e.g.) either ("equation" . (point)) or a list of |
18050 | 4094 ;; them. |
4095 | |
4096 ;; If WHICH is nil, immediately return nil. | |
4097 ;; If WHICH is t, return list of all environments enclosing point. | |
4098 ;; If WHICH is a list of environments, look only for those environments and | |
4099 ;; return the name of the first environment in this list found to enclose | |
4100 ;; point. | |
4101 | |
4102 ;; If the optional BOUND is an integer, bound backwards directed searches to | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
4103 ;; this point. If it is nil, limit to nearest \section - like statement. |
18050 | 4104 |
4105 (catch 'exit | |
4106 (save-excursion | |
4107 (if (null which) (throw 'exit nil)) | |
4108 (let ((bound (or bound (save-excursion (re-search-backward | |
4109 reftex-section-regexp nil 1) | |
4110 (point)))) | |
4111 env-list end-list env) | |
4112 (while (re-search-backward "\\\\\\(begin\\|end\\){\\([^}]+\\)}" | |
4113 bound t) | |
4114 (setq env (buffer-substring-no-properties | |
4115 (match-beginning 2) (match-end 2))) | |
4116 (cond | |
4117 ((string= (match-string 1) "end") | |
4118 (add-to-list 'end-list env)) | |
4119 ((member env end-list) | |
4120 (setq end-list (delete env end-list))) | |
4121 ((eq t which) | |
4122 (setq env-list (cons (cons env (point)) env-list))) | |
4123 ((member env which) | |
4124 (throw 'exit (cons env (point)))))) | |
4125 (nreverse env-list))))) | |
4126 | |
4127 (defun reftex-word-before-point () | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
4128 ;; Return the word before point. Word means here: |
18050 | 4129 ;; Consists of [a-zA-Z0-9.:] and ends at point or whitespace. |
4130 (let ((pos (point))) | |
4131 (save-excursion | |
4132 (re-search-backward "[^ \t\n\r]" (point-min) 1) | |
4133 (setq pos (1+ (point))) | |
4134 (if (re-search-backward "[^a-zA-Z0-9\\\.:]" (point-min) 1) | |
4135 (forward-char 1)) | |
4136 (buffer-substring-no-properties (point) pos)))) | |
4137 | |
4138 ;; ============================================================================ | |
4139 ;; | |
4140 ;; Some generally useful functions | |
4141 | |
4142 (defun reftex-no-props (string) | |
4143 ;; Return STRING with all text properties removed | |
4144 (and (stringp string) | |
4145 (set-text-properties 0 (length string) nil string)) | |
4146 string) | |
4147 | |
4148 (defun reftex-split (regexp string) | |
4149 ;; Split like perl | |
4150 (let ((start 0) list) | |
4151 (while (string-match regexp string start) | |
4152 (setq list (cons (substring string start (match-beginning 0)) list)) | |
4153 (setq start (match-end 0))) | |
4154 (setq list (nreverse (cons (substring string start) list))))) | |
4155 | |
4156 (defun reftex-allow-for-ctrl-m (string) | |
4157 ;; convert STRING into a regexp, allowing ^M for \n | |
4158 (let ((start -2)) | |
4159 (setq string (regexp-quote string)) | |
4160 (while (setq start (string-match "[\n\r]" string (+ 3 start))) | |
4161 (setq string (replace-match "[\n\r]" nil t string))) | |
4162 string)) | |
4163 | |
4164 (defun reftex-delete-list (elt-list list) | |
4165 ;; like delete, but with a list of things to delete | |
4166 ;; (original code from Rory Molinari) | |
4167 (while elt-list | |
4168 (setq list (delete (car elt-list) list) | |
4169 elt-list (cdr elt-list))) | |
4170 list) | |
4171 | |
4172 (defun reftex-get-buffer-visiting (file) | |
4173 ;; return a buffer visiting FILE | |
4174 (cond | |
4175 ((fboundp 'find-buffer-visiting) ; Emacs | |
4176 (find-buffer-visiting file)) | |
4177 ((boundp 'find-file-compare-truenames) ; XEmacs | |
4178 (let ((find-file-compare-truenames t)) | |
4179 (get-file-buffer file))) | |
4180 (t (error "Please report this problem to dominik@strw.leidenuniv.nl")))) | |
4181 | |
4182 (defun reftex-get-file-buffer-force (file &optional mark-to-kill) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
4183 ;; Return a buffer visiting file. Make one, if necessary. |
18050 | 4184 ;; If neither such a buffer no the file exist, return nil. |
4185 ;; If MARK-TO-KILL in non-nil, put any new buffers into the kill list." | |
4186 | |
4187 (let ((buf (reftex-get-buffer-visiting file))) | |
4188 (cond | |
4189 (buf buf) | |
4190 ((file-exists-p file) | |
4191 (setq buf (find-file-noselect file)) | |
4192 (if mark-to-kill | |
4193 (add-to-list 'reftex-buffers-to-kill buf)) | |
4194 buf) | |
4195 (t nil)))) | |
4196 | |
4197 (defun reftex-splice-symbols-into-list (list alist) | |
4198 ;; Splice the association in ALIST of any symbols in LIST into the list. | |
4199 ;; Return new list. | |
4200 (let (rtn tmp) | |
4201 (while list | |
4202 (while (and (not (null (car list))) | |
4203 (symbolp (car list))) | |
4204 (setq tmp (car list)) | |
4205 (cond | |
4206 ((assoc tmp alist) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4207 (setq list (append (nth 2 (assoc tmp alist)) (cdr list)))) |
18050 | 4208 (t |
4209 (error "Cannot treat symbol %s in reftex-label-alist" | |
4210 (symbol-name tmp))))) | |
4211 (setq rtn (cons (car list) rtn) | |
4212 list (cdr list))) | |
4213 (nreverse rtn))) | |
4214 | |
4215 (defun reftex-uniquify (alist &optional keep-list) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
4216 ;; Return a list of all elements in ALIST, but each car only once. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
4217 ;; Elements of KEEP-LIST are not removed even if duplicate. |
18050 | 4218 (let (new elm) |
4219 (while alist | |
4220 (setq elm (car alist) | |
4221 alist (cdr alist)) | |
4222 (if (or (member (car elm) keep-list) | |
4223 (not (assoc (car elm) new))) | |
4224 (setq new (cons elm new)))) | |
4225 (setq new (nreverse new)) | |
4226 new)) | |
4227 | |
4228 (defun reftex-use-fonts () | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
4229 ;; Return t if we can and want to use fonts. |
18050 | 4230 (and window-system |
4231 reftex-use-fonts | |
4232 (boundp 'font-lock-keyword-face))) | |
4233 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
4234 ;; Highlighting uses overlays. If this is for XEmacs, we need to load |
18050 | 4235 ;; the overlay library, available in version 19.15 |
4236 (and (not (fboundp 'make-overlay)) | |
4237 (condition-case nil | |
4238 (require 'overlay) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4239 (error |
18050 | 4240 (error "RefTeX needs overlay emulation (available in XEmacs 19.15)")))) |
4241 | |
4242 ;; We keep a vector with several different overlays to do our highlighting. | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4243 (defvar reftex-highlight-overlays [nil nil nil]) |
18050 | 4244 |
4245 ;; Initialize the overlays | |
4246 (aset reftex-highlight-overlays 0 (make-overlay 1 1)) | |
4247 (overlay-put (aref reftex-highlight-overlays 0) 'face 'highlight) | |
4248 (aset reftex-highlight-overlays 1 (make-overlay 1 1)) | |
4249 (overlay-put (aref reftex-highlight-overlays 1) 'face 'highlight) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4250 (aset reftex-highlight-overlays 2 (make-overlay 1 1)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4251 (overlay-put (aref reftex-highlight-overlays 2) 'face |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4252 (if (string-match "XEmacs" emacs-version) 'zmacs-region 'region)) |
18050 | 4253 |
4254 ;; Two functions for activating and deactivation highlight overlays | |
4255 (defun reftex-highlight (index begin end &optional buffer) | |
4256 "Highlight a region with overlay INDEX." | |
4257 (move-overlay (aref reftex-highlight-overlays index) | |
4258 begin end (or buffer (current-buffer)))) | |
4259 (defun reftex-unhighlight (index) | |
4260 "Detatch overlay INDEX." | |
4261 (delete-overlay (aref reftex-highlight-overlays index))) | |
4262 | |
4263 (defun reftex-highlight-shall-die () | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
4264 ;; Function used in pre-command-hook to remove highlights. |
18050 | 4265 (remove-hook 'pre-command-hook 'reftex-highlight-shall-die) |
4266 (reftex-unhighlight 0)) | |
4267 | |
4268 ;;; --------------------------------------------------------------------------- | |
4269 ;;; | |
4270 ;;; Cursor position after insertion of forms | |
4271 | |
4272 (defun reftex-position-cursor () | |
4273 ;; Search back to question mark, delete it, leave point there | |
4274 (if (search-backward "\?" (- (point) 100) t) | |
4275 (delete-char 1))) | |
4276 | |
4277 (defun reftex-item () | |
4278 "Insert an \\item and provide a label if the environments supports that." | |
4279 (interactive) | |
4280 (let ((env (car | |
4281 (reftex-what-environment '("itemize" "enumerate" "eqnarray"))))) | |
4282 | |
4283 (if (and env (not (bolp))) (newline)) | |
4284 | |
4285 (cond | |
4286 | |
4287 ((string= env "eqnarray") | |
4288 (if (not (bolp)) | |
4289 (newline)) | |
4290 (reftex-label env) | |
4291 (insert "\n & & ") | |
4292 (beginning-of-line 1)) | |
4293 | |
4294 ((string= env "itemize") | |
4295 (newline) | |
4296 (insert "\\item ")) | |
4297 | |
4298 ((string= env "enumerate") | |
4299 (newline) | |
4300 (insert "\\item") | |
4301 (reftex-label env) | |
4302 (insert " ")) | |
4303 (t | |
4304 (error "\\item command does not make sense here..."))))) | |
4305 | |
4306 ;;; --------------------------------------------------------------------------- | |
4307 ;;; --------------------------------------------------------------------------- | |
4308 ;;; --------------------------------------------------------------------------- | |
4309 ;;; | |
4310 ;;; Data Section: Definition of large constants | |
4311 | |
4312 (defconst reftex-label-alist-builtin | |
4313 '( | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4314 ;; Some aliases, mostly for backward compatibility |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4315 (Sideways "Alias for -->rotating" (rotating)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4316 (AMSTeX "Alias for -->amsmath" (amsmath)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4317 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4318 ;; Here come the individual packages of the LaTeX distribution |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4319 (amsmath "AMS math environments" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4320 (("align" ?e "eq:" "~\\eqref{%s}" "\\\\begin{align}\\|\\\\\\\\") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4321 ("gather" ?e "eq:" nil "\\\\begin{gather}\\|\\\\\\\\") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4322 ("multline" ?e "eq:" nil t) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4323 ("flalign" ?e "eq:" nil "\\\\begin{flalign}\\|\\\\\\\\") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4324 ("alignat" ?e "eq:" nil "\\\\begin{alignat}{[0-9]*}\\|\\\\\\\\") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4325 ("xalignat" ?e "eq:" nil "\\\\begin{xalignat}{[0-9]*}\\|\\\\\\\\") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4326 ("xxalignat" ?e "eq:" nil "\\\\begin{xxalignat}{[0-9]*}\\|\\\\\\\\"))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4327 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4328 (longtable "The longtable environment" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4329 (("longtable" ?t nil nil "\\\\caption\\(\\[[^]]*\\]\\)?{"))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4330 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4331 (rotating "Sidewaysfigure and table" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4332 (("sidewaysfigure" ?f nil nil "\\\\caption\\(\\[[^]]*\\]\\)?{") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4333 ("sidewaystable" ?t nil nil "\\\\caption\\(\\[[^]]*\\]\\)?{"))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4334 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4335 (subfigure "Subfigure environments/macro" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4336 (("subfigure" ?f nil nil "\\\\caption\\(\\[[^]]*\\]\\)?{") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4337 ("subfigure*" ?f nil nil "\\\\caption\\(\\[[^]]*\\]\\)?{") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4338 ("\\subfigure" ?f nil nil "\\\\subfigure[[{]"))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4339 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4340 (LaTeX "LaTeX default environments" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4341 (("section" ?s "sec:" "~\\ref{%s}" (nil . t) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4342 ("Part" "Chapter" "Chap." "Section" "Sec." "Sect." "Paragraph" "Par." |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4343 "\\S" "Teil" "Kapitel" "Kap." "Abschnitt" )) |
18050 | 4344 |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4345 ("enumerate" ?n "item:" "~\\ref{%s}" "\\\\item\\(\\[[^]]*\\]\\)?" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4346 ("Item" "Punkt")) |
18050 | 4347 |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4348 ("equation" ?e "eq:" "~(\\ref{%s})" t |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4349 ("Equation" "Eq." "Eqn." "Gleichung" "Gl.")) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4350 ("eqnarray" ?e "eq:" nil "\\\\begin{eqnarray}\\|\\\\\\\\") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4351 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4352 ("figure" ?f "fig:" "~\\ref{%s}" "\\\\caption\\(\\[[^]]*\\]\\)?{" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4353 ("Figure" "Fig." "Abbildung" "Abb.")) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4354 ("figure*" ?f nil nil "\\\\caption\\(\\[[^]]*\\]\\)?{") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4355 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4356 ("table" ?t "tab:" "~\\ref{%s}" "\\\\caption\\(\\[[^]]*\\]\\)?{" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4357 ("Table" "Tab." "Tabelle")) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4358 ("table*" ?t nil nil "\\\\caption\\(\\[[^]]*\\]\\)?{") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4359 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4360 ("any" ?\ " " "\\ref{%s}" nil))) |
18050 | 4361 |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4362 ) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4363 "The default label environment descriptions. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4364 Lower-case symbols correspond to a style file of the same name in the LaTeX |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4365 distribution. Mixed-case symbols are convenience aliases.") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4366 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4367 (defconst reftex-cite-format-builtin |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4368 '( |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4369 (default "Default macro \\cite{%l}" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4370 "\\cite{%l}") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4371 (harvard "P. William's and T. Schnier's Harvard package" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4372 ((?\C-m . "\\cite{%l}") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4373 (?p . "\\cite{%l}") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4374 (?t . "\\citeasnoun{%l}") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4375 (?n . "\\citeasnoun{%l}") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4376 (?s . "\\possessivecite{%l}") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4377 (?e . "\\citeaffixed{%l}{?}") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4378 (?y . "\\citeyear{%l}") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4379 (?a . "\\citename{%l}"))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4380 (natbib "Patrick W. Daly's Natbib package" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4381 ((?\C-m . "\\cite{%l}") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4382 (?t . "\\citet{%l}") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4383 (?T . "\\citet*{%l}") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4384 (?p . "\\citep{%l}") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4385 (?P . "\\citep*{%l}") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4386 (?e . "\\citep[e.g.][]{%l}") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4387 (?a . "\\citeauthor{%l}") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4388 (?y . "\\citeyear{%l}"))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4389 (astron "S. Hogeveen's Astron package" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4390 ((?\C-m . "\\cite{%l}") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4391 (?p . "\\cite{%l}" ) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4392 (?t . "%2a (\\cite{%l})"))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4393 (author-year "Do-it-yourself Author year citation" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4394 ((?\C-m . "\\cite{%l}") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4395 (?t . "%2a (%y)\\nocite{%l}") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4396 (?p . "(%2a %y\\nocite{%l})"))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4397 (locally "Put full info in parenthesis" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4398 "(%2a %y, %j %v, %P, %e: %b, %u, %s %<)") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4399 ;; undocumented feature: `%<' kills white space and punctuation locally. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4400 ) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4401 "Builtin versions of for the citation format. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4402 The following conventions are valid for all alist entries: |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4403 `?\C-m' should always point to a straight \\cite{%l} macro. |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4404 `?t' should point to a textual citation (citation as a noun). |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4405 `?p' should point to a parenthetical citation.") |
18050 | 4406 |
4407 ;;; --------------------------------------------------------------------------- | |
4408 ;;; | |
4409 ;;; Functions to compile the tables, reset the mode etc. | |
4410 | |
4411 (defun reftex-reset-mode () | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
4412 "Reset RefTeX Mode. Required to implement changes to some list variables. |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
4413 This function will compile the information in `reftex-label-alist' and similar |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
4414 variables. It is called when RefTeX is first used, and after changes to |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
4415 these variables via `reftex-add-to-label-alist'." |
18050 | 4416 (interactive) |
4417 | |
18219
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
4418 ;; Record that we have done this |
18050 | 4419 (setq reftex-tables-dirty nil) |
4420 | |
18219
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
4421 ;; Kill temporary buffers associated with RefTeX - just in case they |
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
4422 ;; were not cleaned up properly |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4423 (let ((buffer-list '("*RefTeX Master*" "*RefTeX Help*" "*RefTeX Select*" |
18219
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
4424 "*Duplicate Labels*" "*toc*" "*RefTeX-scratch*"))) |
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
4425 (while buffer-list |
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
4426 (if (get-buffer (car buffer-list)) |
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
4427 (kill-buffer (car buffer-list))) |
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
4428 (setq buffer-list (cdr buffer-list)))) |
aaeaae005e98
Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents:
18123
diff
changeset
|
4429 |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4430 (reftex-reset-scanning-information) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4431 |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
4432 ;; Plug functions into AUCTeX if the user option says so |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
4433 (reftex-plug-into-AUCTeX) |
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
4434 |
18050 | 4435 ;; To update buffer-local variables |
4436 (hack-local-variables) | |
4437 (message "updating internal tables...") | |
4438 (reftex-compute-ref-cite-tables) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4439 (message "updating internal tables... done")) |
18050 | 4440 |
4441 (defun reftex-reset-scanning-information () | |
4442 "Reset the symbols containing information from buffer scanning. | |
4443 This enforces rescanning the buffer on next use." | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4444 (if (string= reftex-last-toc-master (reftex-TeX-master-file)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4445 (reftex-empty-toc-buffer)) |
18050 | 4446 (let ((symlist reftex-multifile-symbols) |
4447 symbol) | |
4448 (while symlist | |
4449 (setq symbol (car symlist) | |
4450 symlist (cdr symlist)) | |
4451 (if (and (symbolp (symbol-value symbol)) | |
4452 (not (null (symbol-value symbol)))) | |
4453 (set (symbol-value symbol) nil))))) | |
4454 | |
4455 (defun reftex-compute-ref-cite-tables () | |
4456 ;; Update ref and cite tables | |
4457 | |
4458 (interactive) | |
4459 | |
4460 ;; Compile information in reftex-label-alist | |
4461 (let ((tmp (reftex-uniquify (reftex-splice-symbols-into-list | |
4462 (append | |
4463 reftex-label-alist | |
4464 reftex-label-alist-external-add-ons | |
4465 reftex-default-label-alist-entries) | |
4466 reftex-label-alist-builtin) | |
4467 '(nil))) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4468 entry env-or-mac typekeychar typekey prefix context |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4469 fmt reffmt labelfmt wordlist qh-list) |
18050 | 4470 |
4471 (setq reftex-words-to-typekey-alist nil | |
4472 reftex-typekey-list nil | |
4473 reftex-typekey-to-format-alist nil | |
4474 reftex-typekey-to-prefix-alist nil | |
4475 reftex-env-or-mac-alist nil | |
4476 reftex-label-env-list nil | |
4477 reftex-label-mac-list nil) | |
4478 (while tmp | |
4479 (catch 'next-entry | |
4480 (setq entry (car tmp) | |
4481 env-or-mac (car entry) | |
4482 entry (cdr entry) | |
4483 tmp (cdr tmp)) | |
4484 (if (null env-or-mac) | |
4485 (setq env-or-mac "")) | |
4486 (if (stringp (car entry)) | |
4487 ;; This is before version 2.00 - convert entry to new format | |
4488 ;; This is just to keep old users happy | |
4489 (setq entry (cons (string-to-char (car entry)) | |
4490 (cons (concat (car entry) ":") | |
4491 (cdr entry))))) | |
4492 (setq typekeychar (nth 0 entry) | |
4493 typekey (char-to-string typekeychar) | |
4494 prefix (nth 1 entry) | |
4495 fmt (nth 2 entry) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4496 context (nth 3 entry) |
18050 | 4497 wordlist (nth 4 entry)) |
4498 (if (stringp wordlist) | |
4499 ;; This is before version 2.04 - convert to new format | |
4500 (setq wordlist (nthcdr 4 entry))) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4501 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4502 (if (and (stringp fmt) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4503 (string-match "@" fmt)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4504 ;; special syntax for specifying a label format |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4505 (setq fmt (reftex-split "@+" fmt)) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4506 (setq fmt (list "\\label{%s}" fmt))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4507 (setq labelfmt (car fmt) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4508 reffmt (nth 1 fmt)) |
18050 | 4509 (if typekey |
4510 (add-to-list 'reftex-typekey-list typekey)) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4511 (if (and typekey prefix |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4512 (not (assoc typekey reftex-typekey-to-prefix-alist))) |
18050 | 4513 (add-to-list 'reftex-typekey-to-prefix-alist (cons typekey prefix))) |
4514 (cond | |
4515 ((string-match "\\`\\\\" env-or-mac) | |
4516 ;; It's a macro | |
4517 (add-to-list 'reftex-label-mac-list env-or-mac)) | |
4518 (t | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4519 (cond ((string= env-or-mac "any")) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4520 ((string= env-or-mac "")) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4521 ((string= env-or-mac "section")) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4522 (t |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4523 (add-to-list 'reftex-label-env-list env-or-mac) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4524 ;; if context is t, translate to skip many parens pairs |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4525 (if (eq t context) (setq context 100)))))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4526 (and reffmt |
18050 | 4527 (not (assoc typekey reftex-typekey-to-format-alist)) |
4528 (setq reftex-typekey-to-format-alist | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4529 (cons (cons typekey reffmt) |
18050 | 4530 reftex-typekey-to-format-alist))) |
4531 (and (not (string= env-or-mac "any")) | |
4532 (not (string= env-or-mac "")) | |
4533 (not (assoc env-or-mac reftex-env-or-mac-alist)) | |
4534 (setq reftex-env-or-mac-alist | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4535 (cons (list env-or-mac typekey context labelfmt) |
18050 | 4536 reftex-env-or-mac-alist))) |
4537 (while (and wordlist (stringp (car wordlist))) | |
4538 (or (assoc (car wordlist) reftex-words-to-typekey-alist) | |
4539 (setq reftex-words-to-typekey-alist | |
4540 (cons (cons (downcase (car wordlist)) typekey) | |
4541 reftex-words-to-typekey-alist))) | |
4542 (setq wordlist (cdr wordlist))) | |
4543 (cond | |
4544 ((string= "" env-or-mac) nil) | |
4545 ((assoc typekey qh-list) | |
4546 (setcdr (assoc typekey qh-list) | |
4547 (concat (cdr (assoc typekey qh-list)) " " env-or-mac))) | |
4548 (t | |
4549 (setq qh-list (cons (cons typekey env-or-mac) qh-list)))))) | |
4550 | |
4551 (setq qh-list (nreverse qh-list)) | |
4552 (setq reftex-typekey-to-prefix-alist | |
4553 (nreverse reftex-typekey-to-prefix-alist)) | |
4554 (setq reftex-type-query-prompt | |
4555 (concat "Label type: " | |
4556 (mapconcat '(lambda(x) | |
4557 (format "[%s]" (car x))) | |
4558 qh-list " ") | |
4559 " (?=Help)")) | |
4560 (setq reftex-type-query-help | |
4561 (concat "SELECT A LABEL TYPE:\n--------------------\n" | |
4562 (mapconcat '(lambda(x) | |
4563 (format " [%s] %s" | |
4564 (car x) (cdr x))) | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4565 qh-list "\n"))) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4566 |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4567 ;; Calculate the section regexp |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4568 (setq reftex-section-regexp |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4569 (concat "^[ ]*\\\\\\(" |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4570 (mapconcat 'car reftex-section-levels "\\|") |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4571 "\\)\\*?\\(\\[[^]]*\\]\\)?{")) |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4572 )) |
18050 | 4573 |
4574 ;;; Keybindings -------------------------------------------------------------- | |
4575 | |
4576 (define-key reftex-mode-map "\C-c-" 'reftex-item) | |
4577 (define-key reftex-mode-map "\C-c=" 'reftex-toc) | |
4578 (define-key reftex-mode-map "\C-c(" 'reftex-label) | |
4579 (define-key reftex-mode-map "\C-c)" 'reftex-reference) | |
4580 (define-key reftex-mode-map "\C-c[" 'reftex-citation) | |
4581 (define-key reftex-mode-map "\C-c&" 'reftex-view-crossref) | |
4582 | |
4583 ;; If the user requests so, she can have a few more bindings: | |
4584 (cond | |
4585 (reftex-extra-bindings | |
4586 (define-key reftex-mode-map "\C-ct" 'reftex-toc) | |
4587 (define-key reftex-mode-map "\C-cl" 'reftex-label) | |
4588 (define-key reftex-mode-map "\C-cr" 'reftex-reference) | |
4589 (define-key reftex-mode-map "\C-cc" 'reftex-citation) | |
4590 (define-key reftex-mode-map "\C-cv" 'reftex-view-crossref) | |
4591 (define-key reftex-mode-map "\C-cg" 'reftex-grep-document) | |
4592 (define-key reftex-mode-map "\C-cs" 'reftex-search-document))) | |
4593 | |
4594 ;;; Menus -------------------------------------------------------------------- | |
4595 | |
4596 ;; Define a menu for the menu bar if Emacs is running under X | |
4597 | |
4598 (require 'easymenu) | |
4599 | |
4600 (easy-menu-define | |
4601 reftex-mode-menu reftex-mode-map | |
4602 "Menu used in RefTeX mode" | |
4603 '("Ref" | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4604 ["Table of Contents" reftex-toc t] |
18050 | 4605 "----" |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4606 ["\\label" reftex-label t] |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4607 ["\\ref" reftex-reference t] |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4608 ["\\cite" reftex-citation t] |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4609 ["View crossref" reftex-view-crossref t] |
18050 | 4610 "----" |
4611 ("Search and Replace" | |
4612 ["Search whole document" reftex-search-document t] | |
4613 ["Replace in document" reftex-query-replace-document t] | |
4614 ["Grep on document" reftex-grep-document t] | |
4615 "----" | |
4616 ["Find duplicate labels" reftex-find-duplicate-labels t] | |
4617 ["Change label and refs" reftex-change-label t] | |
4618 "----" | |
4619 ["Create TAGS file" reftex-create-tags-file t]) | |
4620 "----" | |
4621 ["Parse document" reftex-parse-document t] | |
19660
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4622 ["Reset RefTeX Mode" reftex-reset-mode t] |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4623 ["Show documentation" reftex-show-commentary t] |
fa3d4e7a76d9
(reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents:
18321
diff
changeset
|
4624 ["Customize RefTeX" reftex-customize t])) |
18050 | 4625 |
4626 ;;; Run Hook ------------------------------------------------------------------ | |
4627 | |
4628 (run-hooks 'reftex-load-hook) | |
4629 | |
4630 ;;; That's it! ---------------------------------------------------------------- | |
4631 | |
4632 ; Make sure tabels are compiled | |
4633 (message "updating internal tables...") | |
4634 (reftex-compute-ref-cite-tables) | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
4635 (message "updating internal tables...done") |
18050 | 4636 (setq reftex-tables-dirty nil) |
4637 | |
4638 (provide 'reftex) | |
4639 | |
4640 ;;;============================================================================ | |
4641 | |
18321
0ed97be54a28
Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents:
18220
diff
changeset
|
4642 ;;; reftex.el ends here |