aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/textmodes/reftex.el
diff options
context:
space:
mode:
authorRalf Angeli2012-09-30 22:30:13 +0200
committerRalf Angeli2012-09-30 22:30:13 +0200
commit4f595e1504dfbb6f81e04fb98aa4b033dd5398a4 (patch)
treeaf1c0792865deb6b2a1e986f65ea5a5930f31099 /lisp/textmodes/reftex.el
parent440ba3959311c5085a04d40ce778039b37246fef (diff)
downloademacs-4f595e1504dfbb6f81e04fb98aa4b033dd5398a4.tar.gz
emacs-4f595e1504dfbb6f81e04fb98aa4b033dd5398a4.zip
Merge from standalone RefTeX repository.
Here is the ChangeLog of the standalone version of RefTeX without information about Makefiles and other auxiliary files. The differences to the Emacs repository are documented in the respective ChangeLog files. 2010-11-06 Ralf Angeli <angeli@caeruleus.net> * lisp/reftex-cite.el (reftex-create-bibtex-file): Make sure that entries with whitespace at various places are found. (reftex-extract-bib-entries-from-thebibliography): Remove superfluous backslash. 2010-10-16 Ralf Angeli <angeli@caeruleus.net> * lisp/reftex-cite.el (reftex-extract-bib-entries-from-thebibliography): Use `with-current-buffer'. 2010-09-14 Ralf Angeli <angeli@caeruleus.net> * lisp/reftex-cite.el (reftex-do-citation): Make it possible again to insert non-existent entries. 2010-01-30 Ralf Angeli <angeli@caeruleus.net> * lisp/reftex-base.el (reftex-syntax-table-for-bib, reftex-mode): Do not derive `reftex-syntax-table-for-bib' from `reftex-syntax-table' because parens have to retain their paren syntax in order for parsing of BibTeX entries like @book(...) to work. 2009-09-12 Ralf Angeli <angeli@caeruleus.net> * lisp/reftex-vars.el (reftex-label-alist): Doc fix. * lisp/reftex-toc.el (reftex-re-enlarge): Call `enlarge-window' only if there is something to do because in Emacs the horizontal version throws an error even if the parameter is 0. 2009-08-08 Ralf Angeli <angeli@caeruleus.net> * lisp/reftex-index.el: Suppress byte-compiler warnings. Move provide statement to end of file. * lisp/reftex-dcr.el: Suppress byte-compiler warnings. Move provide statement to end of file. * lisp/reftex-auc.el: Suppress byte-compiler warnings. * doc/reftex.texi (Imprint): Mention Wolfgang in list of contributors. * lisp/reftex-vars.el (reftex-plug-into-AUCTeX): Doc fix. 2009-07-05 Ralf Angeli <angeli@caeruleus.net> * doc/reftex.texi (Creating Citations): Give a hint about how to auto-revert the BibTeX database file when using external editors. * lisp/reftex-cite.el (reftex-do-citation): Save match data when asking for optional arguments. 2009-04-29 Ralf Angeli <angeli@caeruleus.net> * lisp/reftex-base.el (reftex-in-comment): Do not error out if `comment-start-skip' is not set. 2009-03-01 Wolfgang Mayer <wmayer7@gmail.com> * lisp/reftex-cite.el (reftex-all-used-citation-keys): Fix regexp to correctly extract all citations in the same line. 2008-12-29 Ralf Angeli <angeli@caeruleus.net> * lisp/reftex-vars.el (reftex-vref-is-default) (reftex-fref-is-default): Adapt doc string. (reftex-ref-style-default-list): New name for `reftex-ref-style-active-list'. Use :set instead of :repeat. (reftex-vref-is-default, reftex-fref-is-default): Adapt to new name. * lisp/reftex-base.el (reftex-tie-multifile-symbols): Add doc string. (reftex-tie-multifile-symbols): Initialize `reftex-ref-style-list'. (reftex-untie-multifile-symbols): Add doc string. (reftex-add-index-macros): Doc fix. (reftex-ref-style-activate, reftex-ref-style-toggle) (reftex-ref-style-list): New functions. (reftex-mode-menu): Use them. * lisp/reftex-sel.el (reftex-select-cycle-ref-style-internal): Use `reftex-ref-style-list' function. * lisp/reftex-ref.el (reftex-reference): Use `reftex-ref-style-list' function. * doc/reftex.texi (Referencing Labels): Simplify section about reference macro cycling. (Reference Styles, Options (Referencing Labels)): Adapt to changed implementation. 2008-12-18 Ralf Angeli <angeli@caeruleus.net> * lisp/reftex-base.el (reftex-in-comment): Deal correctly with escaped comment characters. 2008-11-30 Ralf Angeli <angeli@caeruleus.net> * lisp/reftex-vars.el (reftex-ref-style-alist): Change structure so that it is not possible to use multiple different package names within a style. (reftex-ref-style-active-list): Adapt to new structure of `reftex-ref-style-alist'. * lisp/reftex-sel.el (reftex-select-cycle-active-ref-styles): Remove. (reftex-select-cycle-ref-style-internal): Adapt to new structure of `reftex-ref-style-alist'. * lisp/reftex-ref.el: Adapt creation of `reftex-<package>-<macro>' functions to new structure of `reftex-ref-style-alist'. (reftex-reference): Adapt to new structure of `reftex-ref-style-alist'. * lisp/reftex-base.el (reftex-mode-menu): Adapt to new structure of `reftex-ref-style-alist'. * doc/reftex.texi (Options (Referencing Labels)): Adapt to new structure of `reftex-ref-style-alist'. 2008-10-16 Ralf Angeli <angeli@caeruleus.net> * doc/reftex.texi (Referencing Labels, Reference Styles): Document changes in the referencing functionality. 2008-10-15 Ralf Angeli <angeli@caeruleus.net> * lisp/reftex-vars.el (reftex-ref-style-alist): Remove the symbols for symbols for macro type distinction. Add characters for macro selection. (reftex-ref-macro-prompt): New variable. * lisp/reftex-sel.el (reftex-select-cycle-ref-style-internal): Remove code for testing macro type. (reftex-select-toggle-numref-pageref): Remove. (reftex-select-label-map): Remove binding for `reftex-select-toggle-numref-pageref'. * lisp/reftex-ref.el (reftex-reference): Prompt for a reference macro if `reftex-ref-macro-prompt' is non-nil. * lisp/reftex-base.el (reftex-select-with-char): Kill the RefTeX Select buffer when done. 2008-06-07 David Kastrup <dak@gnu.org> * lisp/reftex-base.el (reftex-remove-if): Improve performance. 2008-06-07 Ralf Angeli <angeli@caeruleus.net> * lisp/reftex-cite.el (reftex-get-string-refs): Use a regexp alternative for better performance. * doc/reftex.texi (Commands): Mention options for definition of header and footer in BibTeX files. (Options (Creating Citations)): Document `reftex-create-bibtex-header' and `reftex-create-bibtex-footer'. * lisp/reftex-cite.el (reftex-stringref-p): Remove. (reftex-get-string-refs): Do without `reftex-stringref-p' and use `reftex-remove-if' instead of the cl-based `remove-if'. (reftex-create-bibtex-file): Doc fix. * lisp/reftex-base.el (reftex-remove-if): New function. 2008-06-07 Wolfgang Mayer <wmayer7@gmail.com> * lisp/reftex-vars.el (reftex-create-bibtex-header) (reftex-create-bibtex-footer): New variables. * lisp/reftex-cite.el (reftex-parse-bibtex-entry): Accept additional optional argument `raw' and keep quotes or braces if it is non-nil. (reftex-stringref-p, reftex-get-string-refs): New functions. (reftex-create-bibtex-file): Include entries that are cross-referenced from cited entries. Include @String definitions in the resulting bib file. Add header and footer defined in `reftex-create-bibtex-header' and `reftex-create-bibtex-footer'. 2008-05-03 Ralf Angeli <angeli@caeruleus.net> * lisp/reftex-parse.el (reftex-parse-from-file): Move backward one char if a `\' was matched after a section macro. * lisp/reftex-global.el (reftex-isearch-switch-to-next-file): Use `reverse' instead of `nreverse' and `copy-list' in order to make the byte compiler happy. Get rid of unused `orig-flist' variable. * lisp/reftex-base.el (reftex-compile-variables): Revert last change. Match `\' after a section macro. (reftex-mapconcat-with-predicate): Remove. 2008-04-13 Ralf Angeli <angeli@caeruleus.net> * lisp/reftex-base.el (reftex-mapconcat-with-predicate): New function. (reftex-compile-variables): Use it. Treat environments and macros differently in the regexp for section matching. * lisp/reftex-parse.el (reftex-parse-from-file): Use beginning of match instead of end as bound. * lisp/reftex-sel.el (reftex-select-label-map): Changing binding of reference style toggling to "s" which is not already taken. * doc/reftex.texi (Reference Styles): Reflect change in key binding for toggling reference styles. Some minor changes. 2008-03-27 Ralf Angeli <angeli@caeruleus.net> * lisp/reftex-vars.el: Some whitespace, doc and checkdoc fixes. 2008-03-16 Ralf Angeli <angeli@caeruleus.net> * lisp/reftex-index.el (reftex-index-selection-or-word): Use `reftex-region-active-p'. (reftex-index-show-entry) (reftex-index-initialize-phrases-buffer) (reftex-index-phrases-apply-to-region): Sync with Emacs trunk. * lisp/reftex-dcr.el (reftex-start-itimer-once): Silence the byte compiler. * lisp/reftex-auc.el: Move `provide' call to bottom of file. * lisp/reftex-base.el: Require easymenu and define autoloads earlier to avoid compiler warnings. (reftex-region-active-p, reftex-select-with-char) (reftex-show-commentary): Sync with version in Emacs trunk. (reftex-make-overlay, reftex-overlay-put, reftex-move-overlay) (reftex-delete-overlay): Define in a way which hides the XEmacs symbols from the byte compiler. (reftex-info): Silence the byte compiler. Use `reftex.info' instead of `reftex' in order to get the correct file. 2008-03-07 Ralf Angeli <angeli@caeruleus.net> * lisp/reftex-cite.el (reftex-extract-bib-entries): Check if BibTeX file changed on disk and ask if it should be reread in case it did. 2008-03-02 Ralf Angeli <angeli@caeruleus.net> * doc/reftex.texi: Lots of small fixes. (Reference Styles): New section. (varioref (LaTeX package), fancyref (LaTeX package)): Remove. (Options (Referencing Labels)): Remove descriptions of deprecated variables `reftex-vref-is-default' and `reftex-fref-is-default'. Add descriptions for `reftex-ref-style-alist' and `reftex-ref-style-active-list'. (Referencing Labels): Update regarding reference styles. 2008-02-17 Ralf Angeli <angeli@caeruleus.net> * lisp/reftex-ref.el (reftex-format-special): Add third argument for refstyle possible to be passed, making the byte compiler happy. (reftex-reference): Pass refstyle to `reftex-format-special'. * lisp/reftex-vars.el (reftex-ref-style-active-list): Make creation of type compatible with Emacs 21. (reftex-format-ref-function): Mention third argument of special format function. * lisp/reftex-base.el (reftex-mode-menu): Make creation of Reference Style menu compatible with Emacs 21. * doc/reftex.texi: Fix some typos. 2008-01-27 Ralf Angeli <angeli@caeruleus.net> * lisp/reftex-vars.el (reftex-ref-style-active-list): Doc fix. * lisp/reftex-base.el (reftex-erase-all-selection-and-index-buffers) (reftex-access-parse-file): Use `mapc' instead of `mapcar' where return value is not used. * lisp/reftex-ref.el (reftex-offer-label-menu): Use `mapc' instead of `mapcar' where return value is not used. * lisp/reftex-sel.el (reftex-select-item, reftex-select-unmark): Use `mapc' instead of `mapcar' where return value is not used. * lisp/reftex-vars.el (reftex-ref-style-alist) (reftex-ref-style-active-list): New variables. (reftex-vref-is-default, reftex-fref-is-default): Adapt doc string to new implementation. Mark as obsolete. Add compatibility code for honoring the variable values in case they are set. * lisp/reftex-base.el (reftex-mode-menu): Reference styles are now computed from `reftex-ref-style-alist'. Fix typo. * lisp/reftex-ref.el (reftex-reference): Determine reference macro by looking at `reftex-ref-style-active-list' and `reftex-ref-style-alist'. Use only one special format function. (reftex-varioref-vref, reftex-fancyref-fref) (reftex-fancyref-Fref): Remove definitions. The functions are now generated from `reftex-ref-style-alist'. (reftex-format-vref, reftex-format-Fref, reftex-format-fref): Remove. (reftex-format-special): New function. * lisp/reftex-sel.el (reftex-select-toggle-varioref) (reftex-select-toggle-fancyref): Remove. (reftex-select-cycle-active-ref-styles) (reftex-select-cycle-ref-style-internal) (reftex-select-cycle-ref-style-forward) (reftex-select-cycle-ref-style-backward) (reftex-select-toggle-numref-pageref): New functions. (reftex-select-label-map): Use `v' and `V' for general cycling through reference styles. Add `p' for switching between number and page reference types. 2008-01-06 Ralf Angeli <angeli@caeruleus.net> * lisp/reftex-cite.el (reftex-pop-to-bibtex-entry) (reftex-extract-bib-entries-from-thebibliography): Match \bibitem entries with spaces or tabs in front of arguments. (reftex-insert-bib-matches): Use `mapc' instead of `mapcar' because return value is not used. 2008-01-05 Ralf Angeli <angeli@caeruleus.net> * lisp/reftex-toc.el (reftex-make-separate-toc-frame): Hide non-operational call to `focus-frame' in Emacs for the compilers's sake. 2008-01-03 Ralf Angeli <angeli@caeruleus.net> * lisp/reftex-dcr.el (reftex-mouse-view-crossref): Explain why point is set. * lisp/reftex-toc.el (reftex-toc-do-promote): Use `mapc' instead of `mapcar' because return value is not used. (reftex-toggle-auto-toc-recenter): Fix typo. * lisp/reftex-cite.el (reftex-do-citation): Use `mapc' instead of `mapcar' because return value is not used. 2007-10-10 Ralf Angeli <angeli@caeruleus.net> * lisp/reftex-vars.el (reftex-cite-format-builtin) (reftex-bibliography-commands): Add support for ConTeXt. * doc/reftex.texi (Citation Styles): Mention support for ConTeXt. 2007-08-23 Ralf Angeli <angeli@caeruleus.net> * doc/reftex.texi (Options (Defining Label Environments)): Fix typo. 2007-07-22 Ralf Angeli <angeli@caeruleus.net> * lisp/reftex-base.el (reftex-set-cite-format): Autoload. (reftex-access-parse-file): Create parse file in a way that does not interfere with recentf mode. (reftex-access-parse-file): Do not risk destroying an existing buffer. 2007-07-07 Ralf Angeli <angeli@caeruleus.net> * lisp/reftex-parse.el (reftex-nth-arg): Use `forward-comment' instead of `comment-forward'. The latter is not always available and the former is sufficient for LaTeX. (reftex-nth-arg): Revert last change since moving over whitespace and comments is done by `reftex-move-to-next-arg'. 2007-05-20 Ralf Angeli <angeli@caeruleus.net> * doc/reftex.texi (Citation Styles): Correct some mistakes. 2007-04-03 Ralf Angeli <angeli@caeruleus.net> * lisp/reftex-cite.el: Delete trailing whitespace. (reftex-pop-to-bibtex-entry, reftex-extract-bib-entries) (reftex-parse-bibtex-entry, reftex-create-bibtex-file): Match entries containing numbers and symbol constituents. 2007-03-28 Ralf Angeli <angeli@caeruleus.net> * doc/reftex.texi: Replace BibTeX by @BibTeX{} throughout the file. 2007-03-12 John Paul Wallington <jpw@pobox.com> * lisp/reftex-vars.el (reftex-format-ref-function) (reftex-format-cite-function): Fix custom type. 2007-03-10 Ralf Angeli <angeli@caeruleus.net> * lisp/reftex-base.el: Remove information in comment already in imprint or cluttering output of `finder-commentary'. Require reftex.el. * lisp/reftex.el: Remove. Now generated from reftex.el.in. * lisp/reftex-dcr.el: Remove version info in header. Add maintainer info. * lisp/reftex-global.el Remove version info in header. Add maintainer info. * lisp/reftex-index.el Remove version info in header. Add maintainer info. * lisp/reftex-parse.el Remove version info in header. Add maintainer info. * lisp/reftex-ref.el Remove version info in header. Add maintainer info. * lisp/reftex-sel.el Remove version info in header. Add maintainer info. * lisp/reftex-toc.el Remove version info in header. Add maintainer info. * lisp/reftex-vars.el Remove version info in header. Add maintainer info. 2007-03-08 Ralf Angeli <angeli@caeruleus.net> * doc/reftex.texi: Include macros.texi and version.texi. Change maintainer and version information. Express TeX, LaTeX, AUCTeX and RefTeX with macros. (Imprint): Change maintainer information. 2007-03-04 Ralf Angeli <angeli@caeruleus.net> * lisp/reftex.el: Update. * lisp/reftex-base.el (reftex-show-commentary): Look in reftex-base.el. (reftex-report-bug): New function. * lisp/reftex.el: Move original content to reftex-base.el. Add new header and automatically generated autoloads. * lisp/reftex-base.el: New file. Insert original content of reftex.el. Remove autoload for `reftex-index-phrases-mode'. Delete trailing whitespace. 2007-02-26 Ralf Angeli <angeli@caeruleus.net> * lisp/reftex-index.el (reftex-index-visit-phrases-buffer): Set marker when visiting buffer. This allows for returning from the phrases file to the file one was just editing instead of the file where the last phrases was added from. 2007-02-25 Ralf Angeli <angeli@caeruleus.net> * lisp/reftex-index.el (reftex-index-phrases-syntax-table): New variable. Give ?\" punctuation syntax as it usually is not used as string quote in TeX-related modes and may occur unmatched. The change also prevents fontification of quoted content. (reftex-index-phrases-mode): Use it. * lisp/reftex-cite.el (reftex-parse-bibtex-entry): Match fields containing hyphens (besides word constituents). 2007-02-25 David Kastrup <dak@gnu.org> * lisp/reftex.el (reftex-uniquify, reftex-uniquify-by-car): Replace O(n^2) algorithms with O(n log n). Introduce optional argument SORT (not yet used). TODO: figure out callers that can specify SORT, in order to further speed this up. 2007-02-25 Ralf Angeli <angeli@caeruleus.net> * lisp/reftex-vars.el (reftex-cite-key-separator): New variable. * lisp/reftex-auc.el (reftex-arg-cite): Use `reftex-cite-key-separator'. * lisp/reftex-cite.el (reftex-do-citation) (reftex-figure-out-cite-format): Use `reftex-cite-key-separator'. * doc/reftex.texi (Options (Creating Citations)): Document `reftex-cite-key-separator'. * lisp/reftex-cite.el (reftex-do-citation): Return all keys, not just the first one. * lisp/reftex-auc.el (reftex-arg-cite): Correctly handle new value type returned by `reftex-citation'. 2007-02-24 Ralf Angeli <angeli@caeruleus.net> * doc/reftex.texi: Set correct filename for standalone distribution. 2007-02-07 Ralf Angeli <angeli@caeruleus.net> Create `reftex' module.
Diffstat (limited to 'lisp/textmodes/reftex.el')
-rw-r--r--lisp/textmodes/reftex.el651
1 files changed, 273 insertions, 378 deletions
diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el
index 8318dc0d5f3..7052dcf473e 100644
--- a/lisp/textmodes/reftex.el
+++ b/lisp/textmodes/reftex.el
@@ -3,7 +3,6 @@
3 3
4;; Author: Carsten Dominik <dominik@science.uva.nl> 4;; Author: Carsten Dominik <dominik@science.uva.nl>
5;; Maintainer: auctex-devel@gnu.org 5;; Maintainer: auctex-devel@gnu.org
6;; Version: 4.31
7;; Keywords: tex 6;; Keywords: tex
8 7
9;; This file is part of GNU Emacs. 8;; This file is part of GNU Emacs.
@@ -21,10 +20,8 @@
21;; You should have received a copy of the GNU General Public License 20;; You should have received a copy of the GNU General Public License
22;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. 21;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23 22
24;;---------------------------------------------------------------------------
25;;
26;;; Commentary: 23;;; Commentary:
27;; 24
28;; RefTeX is a minor mode with distinct support for \ref, \label, \cite, 25;; RefTeX is a minor mode with distinct support for \ref, \label, \cite,
29;; and \index commands in (multi-file) LaTeX documents. 26;; and \index commands in (multi-file) LaTeX documents.
30;; - A table of contents provides easy access to any part of a document. 27;; - A table of contents provides easy access to any part of a document.
@@ -34,243 +31,23 @@
34;; - Text phrases can be collected in a file, for later global indexing. 31;; - Text phrases can be collected in a file, for later global indexing.
35;; - The index preview buffer helps to check and edit index entries. 32;; - The index preview buffer helps to check and edit index entries.
36;; 33;;
37;; 34;; There is an extensive Texinfo document describing RefTeX in detail.
38;; INSTALLATION
39;; ------------
40;;
41;; - If this file is part of an X/Emacs distribution, it is installed.
42;; - For XEmacs 21.x, you need to install the RefTeX plug-in package
43;; available from the XEmacs distribution sites.
44;; - If you have downloaded this file from the maintainers webpage, follow
45;; the instructions in the INSTALL file of the distribution.
46;;
47;; To turn RefTeX Mode on and off in a buffer, use `M-x reftex-mode'.
48;;
49;; To turn on RefTeX Mode for all LaTeX files, add the following lines
50;; to your init file:
51;;
52;; (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; AUCTeX LaTeX mode
53;; (add-hook 'latex-mode-hook 'turn-on-reftex) ; Emacs latex mode
54;;
55;;
56;; DOCUMENTATION
57;; -------------
58;;
59;; See below for a short summary of how to use RefTeX.
60;;
61;; There is an extensive texinfo document describing RefTeX in detail.
62;; One way to view this documentation is `M-x reftex-info RET'. 35;; One way to view this documentation is `M-x reftex-info RET'.
63;; 36;;
64;; The documentation in various formats is also available at 37;; The documentation in various formats is also available at
65;; 38;;
66;; http://zon.astro.uva.nl/~dominik/Tools/ 39;; http://www.gnu.org/software/auctex/manual/reftex.index.html
67;;
68;;---------------------------------------------------------------------------
69;;
70;; Introduction
71;; ************
72;;
73;; RefTeX is a specialized package for support of labels, references,
74;; citations, and the index in LaTeX. RefTeX wraps itself round 4 LaTeX
75;; macros: `\label', `\ref', `\cite', and `\index'. Using these macros
76;; usually requires looking up different parts of the document and
77;; searching through BibTeX database files. RefTeX automates these
78;; time-consuming tasks almost entirely. It also provides functions to
79;; display the structure of a document and to move around in this
80;; structure quickly.
81;;
82;; *Note Imprint::, for information about who to contact for help, bug
83;; reports or suggestions.
84;;
85;; Environment
86;; ===========
87;;
88;; RefTeX needs to access all files which are part of a multifile
89;; document, and the BibTeX database files requested by the
90;; `\bibliography' command. To find these files, RefTeX will require a
91;; search path, i.e. a list of directories to check. Normally this list
92;; is stored in the environment variables `TEXINPUTS' and `BIBINPUTS'
93;; which are also used by RefTeX. However, on some systems these
94;; variables do not contain the full search path. If RefTeX does not work
95;; for you because it cannot find some files, read *Note Finding Files::.
96;;
97;; Entering RefTeX Mode
98;; ====================
99;;
100;; To turn RefTeX Mode on and off in a particular buffer, use `M-x
101;; reftex-mode'. To turn on RefTeX Mode for all LaTeX files, add the
102;; following lines to your init file:
103;;
104;; (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
105;; (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
106;;
107;; RefTeX in a Nutshell
108;; ====================
109;;
110;; 1. Table of Contents
111;; Typing `C-c =' (`reftex-toc') will show a table of contents of the
112;; document. This buffer can display sections, labels and index
113;; entries defined in the document. From the buffer, you can jump
114;; quickly to every part of your document. Press `?' to get help.
115;;
116;; 2. Labels and References
117;; RefTeX helps to create unique labels and to find the correct key
118;; for references quickly. It distinguishes labels for different
119;; environments, knows about all standard environments (and many
120;; others), and can be configured to recognize any additional labeled
121;; environments you have defined yourself (variable
122;; `reftex-label-alist').
123;;
124;; * Creating Labels
125;; Type `C-c (' (`reftex-label') to insert a label at point.
126;; RefTeX will either
127;; - derive a label from context (default for section labels)
128;; - prompt for a label string (default for figures and
129;; tables) or
130;; - insert a simple label made of a prefix and a number (all
131;; other environments)
132;;
133;; Which labels are created how is configurable with the variable
134;; `reftex-insert-label-flags'.
135;;
136;; * Referencing Labels
137;; To make a reference, type `C-c )' (`reftex-reference'). This
138;; shows an outline of the document with all labels of a certain
139;; type (figure, equation,...) and some label context.
140;; Selecting a label inserts a `\ref{LABEL}' macro into the
141;; original buffer.
142;;
143;; 3. Citations
144;; Typing `C-c [' (`reftex-citation') will let you specify a regular
145;; expression to search in current BibTeX database files (as
146;; specified in the `\bibliography' command) and pull out a list of
147;; matches for you to choose from. The list is _formatted_ and
148;; sorted. The selected article is referenced as `\cite{KEY}' (see
149;; the variable `reftex-cite-format' if you want to insert different
150;; macros).
151;;
152;; 4. Index Support
153;; RefTeX helps to enter index entries. It also compiles all entries
154;; into an alphabetically sorted `*Index*' buffer which you can use
155;; to check and edit the entries. RefTeX knows about the standard
156;; index macros and can be configured to recognize any additional
157;; macros you have defined (`reftex-index-macros'). Multiple indices
158;; are supported.
159;;
160;; * Creating Index Entries
161;; To index the current selection or the word at point, type
162;; `C-c /' (`reftex-index-selection-or-word'). The default macro
163;; `reftex-index-default-macro' will be used. For a more
164;; complex entry type `C-c <' (`reftex-index'), select any of
165;; the index macros and enter the arguments with completion.
166;;
167;; * The Index Phrases File (Delayed Indexing)
168;; Type `C-c \' (`reftex-index-phrase-selection-or-word') to add
169;; the current word or selection to a special _index phrase
170;; file_. RefTeX can later search the document for occurrences
171;; of these phrases and let you interactively index the matches.
172;;
173;; * Displaying and Editing the Index
174;; To display the compiled index in a special buffer, type `C-c
175;; >' (`reftex-display-index'). From that buffer you can check
176;; and edit all entries.
177;;
178;; 5. Viewing Cross-References
179;; When point is on the KEY argument of a cross-referencing macro
180;; (`\label', `\ref', `\cite', `\bibitem', `\index', and variations)
181;; or inside a BibTeX database entry, you can press `C-c &'
182;; (`reftex-view-crossref') to display corresponding locations in the
183;; document and associated BibTeX database files.
184;; When the enclosing macro is `\cite' or `\ref' and no other message
185;; occupies the echo area, information about the citation or label
186;; will automatically be displayed in the echo area.
187;;
188;; 6. Multifile Documents
189;; Multifile Documents are fully supported. The included files must
190;; have a file variable `TeX-master' or `tex-main-file' pointing to
191;; the master file. RefTeX provides cross-referencing information
192;; from all parts of the document, and across document borders
193;; (`xr.sty').
194;;
195;; 7. Document Parsing
196;; RefTeX needs to parse the document in order to find labels and
197;; other information. It does it automatically once and updates its
198;; list internally when `reftex-label' and `reftex-index' are used.
199;; To enforce reparsing, call any of the commands described above
200;; with a raw `C-u' prefix, or press the `r' key in the label
201;; selection buffer, the table of contents buffer, or the index
202;; buffer.
203;;
204;; 8. AUCTeX
205;; If your major LaTeX mode is AUCTeX, RefTeX can cooperate with it
206;; (see variable `reftex-plug-into-AUCTeX'). AUCTeX contains style
207;; files which trigger appropriate settings in RefTeX, so that for
208;; many of the popular LaTeX packages no additional customizations
209;; will be necessary.
210;;
211;; 9. Useful Settings
212;; To make RefTeX faster for large documents, try these:
213;; (setq reftex-enable-partial-scans t)
214;; (setq reftex-save-parse-info t)
215;; (setq reftex-use-multiple-selection-buffers t)
216;;
217;; To integrate with AUCTeX, use
218;; (setq reftex-plug-into-AUCTeX t)
219;;
220;; To make your own LaTeX macro definitions known to RefTeX,
221;; customize the variables
222;; `reftex-label-alist' (for label macros/environments)
223;; `reftex-section-levels' (for sectioning commands)
224;; `reftex-cite-format' (for `\cite'-like macros)
225;; `reftex-index-macros' (for `\index'-like macros)
226;; `reftex-index-default-macro' (to set the default macro)
227;; If you have a large number of macros defined, you may want to write
228;; an AUCTeX style file to support them with both AUCTeX and RefTeX.
229;;
230;; 10. Where Next?
231;; Go ahead and use RefTeX. Use its menus until you have picked up
232;; the key bindings. For an overview of what you can do in each of
233;; the different special buffers, press `?'. Read the manual if you
234;; get stuck, of if you are curious what else might be available.
235;; The first part of the manual explains in a tutorial way how to use
236;; and customize RefTeX. The second part is a command and variable
237;; reference.
238;;
239;;---------------------------------------------------------------------------
240;;
241;; AUTHOR
242;; ======
243;;
244;; Carsten Dominik <dominik@science.uva.nl>
245;;
246;; with contributions from Stephen Eglen
247;; 40;;
248;; RefTeX is bundled with Emacs and available as a plug-in package for 41;; RefTeX is bundled with Emacs and available as a plug-in package for
249;; XEmacs 21.x. If you need to install it yourself, you can find a 42;; XEmacs 21.x. If you need to install it yourself, you can find a
250;; distribution at 43;; distribution at
251;; 44;;
252;; http://zon.astro.uva.nl/~dominik/Tools/ 45;; http://www.gnu.org/software/auctex/reftex.html
253;; 46;;
254;; THANKS TO: 47;; RefTeX was written by Carsten Dominik <dominik@science.uva.nl> with
255;; --------- 48;; contributions from Stephen Eglen. It is currently maintained by
256;; Thanks to the people on the Net who have used RefTeX and helped 49;; the AUCTeX project.
257;; developing it with their reports. In particular thanks to 50
258;;
259;; Fran Burstall, Alastair Burt, Soren Dayton, Stephen Eglen,
260;; Karl Eichwalder, Peter Galbraith, Dieter Kraft, Kai Grossjohann,
261;; Frank Harrell, Adrian Lanz, Rory Molinari, Stefan Monnier,
262;; Laurent Mugnier, Sudeep Kumar Palat, Daniel Polani, Robin Socha,
263;; Richard Stanton, Allan Strand, Jan Vroonhof, Christoph Wedler,
264;; Alan Williams.
265;;
266;; Finally thanks to Uwe Bolick who first got me (some years ago) into
267;; supporting LaTeX labels and references with an editor (which was
268;; MicroEmacs at the time).
269;;
270;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
271;;
272;;;;;;
273
274;;; Code: 51;;; Code:
275 52
276(eval-when-compile (require 'cl)) 53(eval-when-compile (require 'cl))
@@ -289,52 +66,13 @@
289 (set symbol value))) 66 (set symbol value)))
290 67
291 68
292;;; ========================================================================= 69;; Configuration variables
293;;;
294;;; Configuration variables
295
296(require 'reftex-vars) 70(require 'reftex-vars)
297 71
298 72
299;;; ========================================================================= 73;;; Autoloads
300;;;
301;;; Define the formal stuff for a minor mode named RefTeX.
302;;;
303
304(defconst reftex-version "RefTeX version 4.31"
305 "Version string for RefTeX.")
306
307(defvar reftex-mode-map (make-sparse-keymap)
308 "Keymap for RefTeX mode.")
309
310(defvar reftex-mode-menu nil)
311(defvar reftex-syntax-table nil)
312(defvar reftex-syntax-table-for-bib nil)
313
314(unless reftex-syntax-table
315 (setq reftex-syntax-table (copy-syntax-table))
316 (modify-syntax-entry ?\( "." reftex-syntax-table)
317 (modify-syntax-entry ?\) "." reftex-syntax-table))
318
319(unless reftex-syntax-table-for-bib
320 (setq reftex-syntax-table-for-bib
321 (copy-syntax-table reftex-syntax-table))
322 (modify-syntax-entry ?\' "." reftex-syntax-table-for-bib)
323 (modify-syntax-entry ?\" "." reftex-syntax-table-for-bib)
324 (modify-syntax-entry ?\[ "." reftex-syntax-table-for-bib)
325 (modify-syntax-entry ?\] "." reftex-syntax-table-for-bib))
326
327;; The following definitions are out of place, but I need them here
328;; to make the compilation of reftex-mode not complain.
329(defvar reftex-auto-view-crossref-timer nil
330 "The timer used for auto-view-crossref.")
331(defvar reftex-toc-auto-recenter-timer nil
332 "The idle timer used to recenter the toc window.")
333
334;;; =========================================================================
335;;;
336;;; Parser functions
337 74
75;; Parser functions
338(autoload 'reftex-parse-one "reftex-parse" 76(autoload 'reftex-parse-one "reftex-parse"
339 "Re-parse this file." t) 77 "Re-parse this file." t)
340(autoload 'reftex-parse-all "reftex-parse" 78(autoload 'reftex-parse-all "reftex-parse"
@@ -358,11 +96,7 @@
358(autoload 'reftex-ensure-index-support "reftex-parse") 96(autoload 'reftex-ensure-index-support "reftex-parse")
359(autoload 'reftex-everything-regexp "reftex-parse") 97(autoload 'reftex-everything-regexp "reftex-parse")
360 98
361 99;; Labels and References
362;;; =========================================================================
363;;;
364;;; Labels and References
365
366(autoload 'reftex-label-location "reftex-ref") 100(autoload 'reftex-label-location "reftex-ref")
367(autoload 'reftex-label-info-update "reftex-ref") 101(autoload 'reftex-label-info-update "reftex-ref")
368(autoload 'reftex-label-info "reftex-ref") 102(autoload 'reftex-label-info "reftex-ref")
@@ -381,10 +115,7 @@
381(autoload 'reftex-goto-label "reftex-ref" 115(autoload 'reftex-goto-label "reftex-ref"
382 "Prompt for label name and go to that location." t) 116 "Prompt for label name and go to that location." t)
383 117
384;;; ========================================================================= 118;; Table of contents
385;;;
386;;; Table of contents
387
388(autoload 'reftex-toc "reftex-toc" 119(autoload 'reftex-toc "reftex-toc"
389 "Show the table of contents for the current document." t) 120 "Show the table of contents for the current document." t)
390(autoload 'reftex-toc-recenter "reftex-toc" 121(autoload 'reftex-toc-recenter "reftex-toc"
@@ -392,10 +123,7 @@
392(autoload 'reftex-toggle-auto-toc-recenter "reftex-toc" 123(autoload 'reftex-toggle-auto-toc-recenter "reftex-toc"
393 "Toggle automatic recentering of TOC window." t) 124 "Toggle automatic recentering of TOC window." t)
394 125
395;;; ========================================================================= 126;; BibTeX citations.
396;;;
397;;; BibTeX citations.
398
399(autoload 'reftex-citep "reftex-cite") 127(autoload 'reftex-citep "reftex-cite")
400(autoload 'reftex-citet "reftex-cite") 128(autoload 'reftex-citet "reftex-cite")
401(autoload 'reftex-make-cite-echo-string "reftex-cite") 129(autoload 'reftex-make-cite-echo-string "reftex-cite")
@@ -409,10 +137,7 @@
409(autoload 'reftex-bib-or-thebib "reftex-cite") 137(autoload 'reftex-bib-or-thebib "reftex-cite")
410(autoload 'reftex-create-bibtex-file "reftex-cite") 138(autoload 'reftex-create-bibtex-file "reftex-cite")
411 139
412;;; ========================================================================= 140;; Selection
413;;;
414;;; Selection
415
416(autoload 'reftex-select-label-mode "reftex-sel") 141(autoload 'reftex-select-label-mode "reftex-sel")
417(autoload 'reftex-select-bib-mode "reftex-sel") 142(autoload 'reftex-select-bib-mode "reftex-sel")
418(autoload 'reftex-find-start-point "reftex-sel") 143(autoload 'reftex-find-start-point "reftex-sel")
@@ -420,11 +145,7 @@
420(autoload 'reftex-get-offset "reftex-sel") 145(autoload 'reftex-get-offset "reftex-sel")
421(autoload 'reftex-select-item "reftex-sel") 146(autoload 'reftex-select-item "reftex-sel")
422 147
423 148;; Index support
424;;; =========================================================================
425;;;
426;;; Index support
427
428(autoload 'reftex-index "reftex-index" 149(autoload 'reftex-index "reftex-index"
429 "Query for an index macro and insert it along with its arguments." t) 150 "Query for an index macro and insert it along with its arguments." t)
430(autoload 'reftex-index-selection-or-word "reftex-index" 151(autoload 'reftex-index-selection-or-word "reftex-index"
@@ -442,11 +163,7 @@
442(autoload 'reftex-index-show-entry "reftex-index") 163(autoload 'reftex-index-show-entry "reftex-index")
443(autoload 'reftex-index-select-tag "reftex-index") 164(autoload 'reftex-index-select-tag "reftex-index")
444 165
445 166;; View cross references
446;;; =========================================================================
447;;;
448;;; View cross references
449
450(autoload 'reftex-view-crossref "reftex-dcr" 167(autoload 'reftex-view-crossref "reftex-dcr"
451 "View cross reference of \\ref or \\cite macro at point." t) 168 "View cross reference of \\ref or \\cite macro at point." t)
452(autoload 'reftex-mouse-view-crossref "reftex-dcr" 169(autoload 'reftex-mouse-view-crossref "reftex-dcr"
@@ -455,11 +172,7 @@
455(autoload 'reftex-view-crossref-from-bibtex "reftex-dcr" 172(autoload 'reftex-view-crossref-from-bibtex "reftex-dcr"
456 "View location in a LaTeX document which cites the BibTeX entry at point." t) 173 "View location in a LaTeX document which cites the BibTeX entry at point." t)
457 174
458 175;; Operations on entire Multifile documents
459;;; =========================================================================
460;;;
461;;; Operations on entire Multifile documents
462
463(autoload 'reftex-create-tags-file "reftex-global" 176(autoload 'reftex-create-tags-file "reftex-global"
464 "Create TAGS file by running `etags' on the current document." t) 177 "Create TAGS file by running `etags' on the current document." t)
465(autoload 'reftex-grep-document "reftex-global" 178(autoload 'reftex-grep-document "reftex-global"
@@ -477,11 +190,7 @@
477(autoload 'reftex-save-all-document-buffers "reftex-global" 190(autoload 'reftex-save-all-document-buffers "reftex-global"
478 "Save all documents associated with the current document." t) 191 "Save all documents associated with the current document." t)
479 192
480 193;; AUCTeX Interface
481;;; =========================================================================
482;;;
483;;; AUCTeX Interface
484
485(autoload 'reftex-arg-label "reftex-auc") 194(autoload 'reftex-arg-label "reftex-auc")
486(autoload 'reftex-arg-cite "reftex-auc") 195(autoload 'reftex-arg-cite "reftex-auc")
487(autoload 'reftex-arg-index-tag "reftex-auc") 196(autoload 'reftex-arg-index-tag "reftex-auc")
@@ -494,6 +203,41 @@
494(autoload 'reftex-add-section-levels "reftex-auc") 203(autoload 'reftex-add-section-levels "reftex-auc")
495(autoload 'reftex-notice-new-section "reftex-auc") 204(autoload 'reftex-notice-new-section "reftex-auc")
496 205
206
207;;; =========================================================================
208;;;
209;;; Define the formal stuff for a minor mode named RefTeX.
210;;;
211
212(defconst reftex-version emacs-version
213 "Version string for RefTeX.")
214
215(defvar reftex-mode-map (make-sparse-keymap)
216 "Keymap for RefTeX mode.")
217
218(defvar reftex-mode-menu nil)
219(defvar reftex-syntax-table nil)
220(defvar reftex-syntax-table-for-bib nil)
221
222(unless reftex-syntax-table
223 (setq reftex-syntax-table (copy-syntax-table))
224 (modify-syntax-entry ?\( "." reftex-syntax-table)
225 (modify-syntax-entry ?\) "." reftex-syntax-table))
226
227(unless reftex-syntax-table-for-bib
228 (setq reftex-syntax-table-for-bib (copy-syntax-table))
229 (modify-syntax-entry ?\' "." reftex-syntax-table-for-bib)
230 (modify-syntax-entry ?\" "." reftex-syntax-table-for-bib)
231 (modify-syntax-entry ?\[ "." reftex-syntax-table-for-bib)
232 (modify-syntax-entry ?\] "." reftex-syntax-table-for-bib))
233
234;; The following definitions are out of place, but I need them here
235;; to make the compilation of reftex-mode not complain.
236(defvar reftex-auto-view-crossref-timer nil
237 "The timer used for auto-view-crossref.")
238(defvar reftex-toc-auto-recenter-timer nil
239 "The idle timer used to recenter the toc window.")
240
497;;;###autoload 241;;;###autoload
498(defun turn-on-reftex () 242(defun turn-on-reftex ()
499 "Turn on RefTeX mode." 243 "Turn on RefTeX mode."
@@ -503,13 +247,7 @@
503(put 'reftex-mode :menu-tag "RefTeX Mode") 247(put 'reftex-mode :menu-tag "RefTeX Mode")
504;;;###autoload 248;;;###autoload
505(define-minor-mode reftex-mode 249(define-minor-mode reftex-mode
506 "Toggle RefTeX mode. 250 "Minor mode with distinct support for \\label, \\ref and \\cite in LaTeX.
507With a prefix argument ARG, enable RefTeX mode if ARG is
508positive, and disable it otherwise. If called from Lisp, enable
509the mode if ARG is omitted or nil.
510
511RefTeX mode is a buffer-local minor mode with distinct support
512for \\label, \\ref and \\cite in LaTeX.
513 251
514\\<reftex-mode-map>A Table of Contents of the entire (multifile) document with browsing 252\\<reftex-mode-map>A Table of Contents of the entire (multifile) document with browsing
515capabilities is available with `\\[reftex-toc]'. 253capabilities is available with `\\[reftex-toc]'.
@@ -559,8 +297,7 @@ on the menu bar.
559 (modify-syntax-entry ?\( "." reftex-syntax-table) 297 (modify-syntax-entry ?\( "." reftex-syntax-table)
560 (modify-syntax-entry ?\) "." reftex-syntax-table) 298 (modify-syntax-entry ?\) "." reftex-syntax-table)
561 299
562 (setq reftex-syntax-table-for-bib 300 (setq reftex-syntax-table-for-bib (copy-syntax-table))
563 (copy-syntax-table reftex-syntax-table))
564 (modify-syntax-entry ?\' "." reftex-syntax-table-for-bib) 301 (modify-syntax-entry ?\' "." reftex-syntax-table-for-bib)
565 (modify-syntax-entry ?\" "." reftex-syntax-table-for-bib) 302 (modify-syntax-entry ?\" "." reftex-syntax-table-for-bib)
566 (modify-syntax-entry ?\[ "." reftex-syntax-table-for-bib) 303 (modify-syntax-entry ?\[ "." reftex-syntax-table-for-bib)
@@ -635,16 +372,15 @@ on the menu bar.
635 (incf reftex-multifile-index)) 372 (incf reftex-multifile-index))
636 373
637(defun reftex-tie-multifile-symbols () 374(defun reftex-tie-multifile-symbols ()
638 ;; Tie the buffer-local symbols to globals connected with the master file. 375 "Tie the buffer-local symbols to globals connected with the master file.
639 ;; If the symbols for the current master file do not exist, they are created. 376If the symbols for the current master file do not exist, they are created."
640
641 (let* ((master (file-truename (reftex-TeX-master-file))) 377 (let* ((master (file-truename (reftex-TeX-master-file)))
642 (index (assoc master reftex-master-index-list)) 378 (index (assoc master reftex-master-index-list))
643 (symlist reftex-multifile-symbols) 379 (symlist reftex-multifile-symbols)
644 symbol symname newflag) 380 symbol symname newflag)
645 ;; Find the correct index. 381 ;; Find the correct index.
646 (if index 382 (if index
647 ;; symbols do exist 383 ;; Symbols do exist
648 (setq index (cdr index)) 384 (setq index (cdr index))
649 ;; Get a new index and add info to the alist. 385 ;; Get a new index and add info to the alist.
650 (setq index (reftex-next-multifile-index) 386 (setq index (reftex-next-multifile-index)
@@ -661,13 +397,15 @@ on the menu bar.
661 ;; Initialize if new symbols. 397 ;; Initialize if new symbols.
662 (when newflag 398 (when newflag
663 (set (symbol-value symbol) nil) 399 (set (symbol-value symbol) nil)
664 (put (symbol-value symbol) 'reftex-index-macros-style '(default)))) 400 (put (symbol-value symbol) 'reftex-index-macros-style '(default))
401 (put (symbol-value symbol) 'reftex-ref-style-list
402 reftex-ref-style-default-list)))
665 403
666 ;; Return t if the symbols did already exist, nil when we've made them. 404 ;; Return t if the symbols did already exist, nil when we've made them.
667 (not newflag))) 405 (not newflag)))
668 406
669(defun reftex-untie-multifile-symbols () 407(defun reftex-untie-multifile-symbols ()
670 ;; Remove ties from multifile symbols, so that next use makes new ones. 408 "Remove ties from multifile symbols, so that next use makes new ones."
671 (let ((symlist reftex-multifile-symbols) 409 (let ((symlist reftex-multifile-symbols)
672 (symbol nil)) 410 (symbol nil))
673 (while symlist 411 (while symlist
@@ -761,7 +499,7 @@ for details.
761This function makes it possible to support RefTeX from AUCTeX style files. 499This function makes it possible to support RefTeX from AUCTeX style files.
762The entries in ENTRY-LIST will be processed after the user settings in 500The entries in ENTRY-LIST will be processed after the user settings in
763`reftex-index-entries', and before the defaults. Any changes made to 501`reftex-index-entries', and before the defaults. Any changes made to
764`reftex-label-alist-style' will raise a flag to the effect that 502`reftex-index-macros-style' will raise a flag to the effect that
765the label information is recompiled on next use." 503the label information is recompiled on next use."
766 (unless reftex-docstruct-symbol 504 (unless reftex-docstruct-symbol
767 (reftex-tie-multifile-symbols)) 505 (reftex-tie-multifile-symbols))
@@ -783,6 +521,52 @@ the label information is recompiled on next use."
783 (when changed 521 (when changed
784 (put reftex-docstruct-symbol 'reftex-index-macros-style list))))) 522 (put reftex-docstruct-symbol 'reftex-index-macros-style list)))))
785 523
524(defun reftex-ref-style-activate (style)
525 "Activate the referencing style STYLE."
526 (reftex-ref-style-toggle style 'activate))
527
528(defun reftex-ref-style-toggle (style &optional action)
529 "Activate or deactivate the referencing style STYLE.
530With the optional argument ACTION a certain action can be forced.
531The symbol `activate' will activate the style and `deactivate'
532will deactivate it."
533 (unless reftex-docstruct-symbol
534 (reftex-tie-multifile-symbols))
535 (when (and reftex-docstruct-symbol
536 (symbolp reftex-docstruct-symbol))
537 (let ((list (get reftex-docstruct-symbol 'reftex-ref-style-list))
538 changed)
539 (cond ((eq action 'activate)
540 (unless (member style list)
541 (setq reftex-tables-dirty t
542 changed t)
543 (add-to-list 'list style t)))
544 ((eq action 'deactivate)
545 (when (member style list)
546 (setq reftex-tables-dirty t
547 changed t)
548 (delete style list)))
549 (t
550 (if (member style list)
551 (delete style list)
552 (add-to-list 'list style t))
553 (setq reftex-tables-dirty t
554 changed t)))
555 (when changed
556 (put reftex-docstruct-symbol 'reftex-ref-style-list list)))))
557
558(defun reftex-ref-style-list ()
559 "Return the list of referencing styles to be active at the moment."
560 ;; Initialize the value of `reftex-ref-style-list' and tie it to the
561 ;; docstruct symbol if necessary.
562 (unless reftex-docstruct-symbol
563 (reftex-tie-multifile-symbols))
564 (if (and reftex-docstruct-symbol
565 (symbolp reftex-docstruct-symbol)
566 (get reftex-docstruct-symbol 'reftex-ref-style-list))
567 (get reftex-docstruct-symbol 'reftex-ref-style-list)
568 reftex-ref-style-default-list))
569
786;;; ========================================================================= 570;;; =========================================================================
787;;; 571;;;
788;;; Functions to compile the tables, reset the mode etc. 572;;; Functions to compile the tables, reset the mode etc.
@@ -1282,8 +1066,8 @@ This enforces rescanning the buffer on next use."
1282 ;; Calculate the regular expressions 1066 ;; Calculate the regular expressions
1283 (let* ( 1067 (let* (
1284; (wbol "\\(\\`\\|[\n\r]\\)[ \t]*") 1068; (wbol "\\(\\`\\|[\n\r]\\)[ \t]*")
1285 (wbol "\\(^\\)[ \t]*") ; Need to keep the empty group because 1069 (wbol "\\(^\\)[ \t]*") ; Need to keep the empty group because
1286 ;;; because match number are hard coded 1070 ; match numbers are hard coded
1287 (label-re (concat "\\(?:" 1071 (label-re (concat "\\(?:"
1288 ;; Normal \label{...} 1072 ;; Normal \label{...}
1289 "\\\\label{\\([^}]*\\)}" 1073 "\\\\label{\\([^}]*\\)}"
@@ -1299,10 +1083,16 @@ This enforces rescanning the buffer on next use."
1299 reftex-include-file-commands "\\|") 1083 reftex-include-file-commands "\\|")
1300 "\\)[{ \t]+\\([^} \t\n\r]+\\)")) 1084 "\\)[{ \t]+\\([^} \t\n\r]+\\)"))
1301 (section-re 1085 (section-re
1086 ;; Including `\' as a character to be matched at the end
1087 ;; of the regexp will allow stuff like
1088 ;; \begin{foo}\label{bar} to be matched. This will make
1089 ;; the parser to advance one char too much. Therefore
1090 ;; `reftex-parse-from-file' will step one char back if a
1091 ;; section is found.
1302 (concat wbol "\\\\\\(" 1092 (concat wbol "\\\\\\("
1303 (mapconcat (lambda (x) (regexp-quote (car x))) 1093 (mapconcat (lambda (x) (regexp-quote (car x)))
1304 reftex-section-levels-all "\\|") 1094 reftex-section-levels-all "\\|")
1305 "\\)\\*?\\(\\[[^]]*\\]\\)?[[{ \t\r\n]")) 1095 "\\)\\*?\\(\\[[^]]*\\]\\)?[[{ \t\r\n\\]"))
1306 (appendix-re (concat wbol "\\(\\\\appendix\\)")) 1096 (appendix-re (concat wbol "\\(\\\\appendix\\)"))
1307 (macro-re 1097 (macro-re
1308 (if macros-with-labels 1098 (if macros-with-labels
@@ -1780,9 +1570,18 @@ When DIE is non-nil, throw an error if file not found."
1780 "In unfinished selection process. Finish, or abort with \\[abort-recursive-edit]")))) 1570 "In unfinished selection process. Finish, or abort with \\[abort-recursive-edit]"))))
1781 1571
1782(defun reftex-in-comment () 1572(defun reftex-in-comment ()
1573 "Return non-nil if point is in a comment."
1783 (save-excursion 1574 (save-excursion
1784 (skip-chars-backward "^%\n\r") 1575 (save-match-data
1785 (eq (preceding-char) ?%))) 1576 (let ((pos (point)))
1577 (beginning-of-line)
1578 (re-search-forward
1579 (or comment-start-skip
1580 ;; The parser may open files in fundamental mode if
1581 ;; `reftex-initialize-temporary-buffers' is nil, so here
1582 ;; is a default suitable for plain TeX and LaTeX.
1583 "\\(\\(^\\|[^\\\n]\\)\\(\\\\\\\\\\)*\\)\\(%+[ \t]*\\)")
1584 pos t)))))
1786 1585
1787(defun reftex-no-props (string) 1586(defun reftex-no-props (string)
1788 ;; Return STRING with all text properties removed 1587 ;; Return STRING with all text properties removed
@@ -1996,6 +1795,7 @@ When DIE is non-nil, throw an error if file not found."
1996 (condition-case nil (scroll-down) (error nil)) 1795 (condition-case nil (scroll-down) (error nil))
1997 (message "%s" prompt)) 1796 (message "%s" prompt))
1998 (t (message "") 1797 (t (message "")
1798 (reftex-kill-buffer "*RefTeX Select*")
1999 (throw 'exit char))) 1799 (throw 'exit char)))
2000 (setq char (read-char-exclusive))))))) 1800 (setq char (read-char-exclusive)))))))
2001 1801
@@ -2123,25 +1923,95 @@ When DIE is non-nil, throw an error if file not found."
2123 (setq list (cdr list))) 1923 (setq list (cdr list)))
2124 (nreverse rtn))) 1924 (nreverse rtn)))
2125 1925
2126(defun reftex-uniquify (list) 1926(defun reftex-uniquify (list &optional sort)
2127 ;; Return a list of all elements in LIST, but each only once, keeping order 1927 ;; Return a list of all strings in LIST, but each only once, keeping order
2128 (let (new elm) 1928 ;; unless SORT is set (faster!).
2129 (while list 1929 (setq list (copy-sequence list))
2130 (setq elm (pop list)) 1930 (if sort
2131 (unless (member elm new) 1931 (progn
2132 (push elm new))) 1932 (setq list (sort list 'string<))
2133 (nreverse new))) 1933 (let ((p list))
2134 1934 (while (cdr p)
2135(defun reftex-uniquify-by-car (alist &optional keep-list) 1935 (if (string= (car p) (car (cdr p)))
1936 (setcdr p (cdr (cdr p)))
1937 (setq p (cdr p)))))
1938 list)
1939 (let ((p list) lst elt)
1940 ;; push all sublists into lst in reverse(!) order
1941 (while p
1942 (push p lst)
1943 (setq p (cdr p)))
1944 ;; sort all sublists
1945 (setq lst (sort lst (lambda (x1 x2) (string< (car x1) (car x2)))))
1946 (while (cdr lst)
1947 (setq elt (car (car lst)))
1948 ;; for equal elements in the sorted sublist, replace the
1949 ;; last(!) original list member with nil
1950 (when (string= elt (car (cadr lst)))
1951 (setcar (pop lst) nil)
1952 (while (and (cdr lst) (string= elt (car (cadr lst))))
1953 (setcar (pop lst) nil)))
1954 (pop lst)))
1955 ;; weed out all nils and return.
1956 (delq nil list)))
1957
1958(defun reftex-uniquify-by-car (alist &optional keep-list sort)
2136 ;; Return a list of all elements in ALIST, but each car only once. 1959 ;; Return a list of all elements in ALIST, but each car only once.
2137 ;; Elements of KEEP-LIST are not removed even if duplicate. 1960 ;; Elements of KEEP-LIST are not removed even if duplicate.
2138 (let (new elm) 1961 ;; The order is kept unless SORT is set (faster!).
2139 (while alist 1962 (setq keep-list (sort (copy-sequence keep-list) #'string<)
2140 (setq elm (pop alist)) 1963 alist (copy-sequence alist))
2141 (if (or (member (car elm) keep-list) 1964 (if sort
2142 (not (assoc (car elm) new))) 1965 (let (lst elt)
2143 (push elm new))) 1966 (setq alist (sort alist (lambda(a b) (string< (car a) (car b)))))
2144 (nreverse new))) 1967 (setq lst alist)
1968 (while (cdr lst)
1969 (setq elt (car (car lst)))
1970 (when (string= elt (car (cadr lst)))
1971 (while (and keep-list (string< (car keep-list) elt))
1972 (pop keep-list))
1973 (if (and keep-list (string= elt (car keep-list)))
1974 (progn
1975 (pop lst)
1976 (while (and (cdr lst)
1977 (string= elt (car (cadr lst))))
1978 (pop lst)))
1979 (setcdr lst (cdr (cdr lst)))
1980 (while (and (cdr lst)
1981 (string= elt (car (cadr lst))))
1982 (setcdr lst (cdr (cdr lst))))))
1983 (pop lst))
1984 alist)
1985 (let ((p alist) lst elt)
1986 (while p
1987 (push p lst)
1988 (setq p (cdr p)))
1989 (setq lst (sort lst (lambda(a b) (string< (car (car a))
1990 (car (car b))))))
1991 (while (cdr lst)
1992 (setq elt (car (car (car lst))))
1993 (when (string= elt (car (car (cadr lst))))
1994 (while (and keep-list (string< (car keep-list) elt))
1995 (pop keep-list))
1996 (if (and keep-list (string= elt (car keep-list)))
1997 (progn
1998 (pop lst)
1999 (while (and (cdr lst)
2000 (string= elt (car (car (cadr lst)))))
2001 (pop lst)))
2002 (setcar (pop lst) nil)
2003 (while (and (cdr lst)
2004 (string= elt (car (car (cadr lst)))))
2005 (setcar (pop lst) nil))))
2006 (pop lst)))
2007 (delq nil alist)))
2008
2009(defun reftex-remove-if (predicate list)
2010 "Nondestructively remove all items from LIST which satisfy PREDICATE."
2011 (let (result)
2012 (dolist (elt list (nreverse result))
2013 (unless (funcall predicate elt)
2014 (push elt result)))))
2145 2015
2146(defun reftex-abbreviate-title (string) 2016(defun reftex-abbreviate-title (string)
2147 (reftex-convert-string string "[-~ \t\n\r,;]" nil t t 2017 (reftex-convert-string string "[-~ \t\n\r,;]" nil t t
@@ -2243,6 +2113,7 @@ IGNORE-WORDS List of words which should be removed from the string."
2243 ((= (length text) 0) (make-string 1 ?\ )) 2113 ((= (length text) 0) (make-string 1 ?\ ))
2244 (t text))) 2114 (t text)))
2245 2115
2116
2246;;; ========================================================================= 2117;;; =========================================================================
2247;;; 2118;;;
2248;;; Fontification and Highlighting 2119;;; Fontification and Highlighting
@@ -2390,28 +2261,20 @@ IGNORE-WORDS List of words which should be removed from the string."
2390 "bibtex" 2261 "bibtex"
2391 '(define-key bibtex-mode-map "\C-c&" 'reftex-view-crossref-from-bibtex)) 2262 '(define-key bibtex-mode-map "\C-c&" 'reftex-view-crossref-from-bibtex))
2392 2263
2393;; If the user requests so, she can have a few more bindings:
2394;; For most of these commands there are already bindings in place. 2264;; For most of these commands there are already bindings in place.
2395;; Setting `reftex-extra-bindings' really is only there to spare users 2265;; Setting `reftex-extra-bindings' really is only there to spare users
2396;; the hassle of defining bindings in the user space themselves. This 2266;; the hassle of defining bindings in the user space themselves. This
2397;; is why they violate the key binding recommendations. 2267;; is why they violate the key binding recommendations.
2398(defvar reftex-extra-bindings-map
2399 (let ((map (make-sparse-keymap)))
2400 (define-key map "t" 'reftex-toc)
2401 (define-key map "l" 'reftex-label)
2402 (define-key map "r" 'reftex-reference)
2403 (define-key map "c" 'reftex-citation)
2404 (define-key map "v" 'reftex-view-crossref)
2405 (define-key map "g" 'reftex-grep-document)
2406 (define-key map "s" 'reftex-search-document)
2407 map)
2408 "Reftex extra bindings map")
2409
2410(when reftex-extra-bindings 2268(when reftex-extra-bindings
2411 (define-key reftex-mode-map 2269 (loop for x in
2412 reftex-extra-bindings-prefix 2270 '(("\C-ct" . reftex-toc)
2413 reftex-extra-bindings-map)) 2271 ("\C-cl" . reftex-label)
2414 2272 ("\C-cr" . reftex-reference)
2273 ("\C-cc" . reftex-citation)
2274 ("\C-cv" . reftex-view-crossref)
2275 ("\C-cg" . reftex-grep-document)
2276 ("\C-cs" . reftex-search-document))
2277 do (define-key reftex-mode-map (car x) (cdr x))))
2415 2278
2416;;; ========================================================================= 2279;;; =========================================================================
2417;;; 2280;;;
@@ -2488,21 +2351,22 @@ IGNORE-WORDS List of words which should be removed from the string."
2488 :style radio :selected (eq reftex-auto-view-crossref 'window)] 2351 :style radio :selected (eq reftex-auto-view-crossref 'window)]
2489 "--" 2352 "--"
2490 "MISC" 2353 "MISC"
2491 ["AUC TeX Interface" reftex-toggle-plug-into-AUCTeX 2354 ["AUCTeX Interface" reftex-toggle-plug-into-AUCTeX
2492 :style toggle :selected reftex-plug-into-AUCTeX] 2355 :style toggle :selected reftex-plug-into-AUCTeX]
2493 ["isearch whole document" reftex-isearch-minor-mode 2356 ["isearch whole document" reftex-isearch-minor-mode
2494 :style toggle :selected reftex-isearch-minor-mode]) 2357 :style toggle :selected reftex-isearch-minor-mode])
2495 ("Reference Style" 2358 ("Reference Style"
2496 ["Default" (setq reftex-vref-is-default nil 2359 ,@(let (list item)
2497 reftex-fref-is-default nil) 2360 (dolist (elt reftex-ref-style-alist)
2498 :style radio :selected (not (or reftex-vref-is-default 2361 (setq elt (car elt)
2499 reftex-fref-is-default))] 2362 item (vector
2500 ["Varioref" (setq reftex-vref-is-default t 2363 elt
2501 reftex-fref-is-default nil) 2364 `(reftex-ref-style-toggle ,elt)
2502 :style radio :selected reftex-vref-is-default] 2365 :style 'toggle
2503 ["Fancyref" (setq reftex-fref-is-default t 2366 :selected `(member ,elt (reftex-ref-style-list))))
2504 reftex-vref-is-default nil) 2367 (unless (member item list)
2505 :style radio :selected reftex-fref-is-default]) 2368 (add-to-list 'list item t)))
2369 list))
2506 ("Citation Style" 2370 ("Citation Style"
2507 ,@(mapcar 2371 ,@(mapcar
2508 (lambda (x) 2372 (lambda (x)
@@ -2568,6 +2432,9 @@ IGNORE-WORDS List of words which should be removed from the string."
2568 (message "\"Ref\"-menu now contains full customization menu")) 2432 (message "\"Ref\"-menu now contains full customization menu"))
2569 (error "Cannot expand menu (outdated version of cus-edit.el)"))) 2433 (error "Cannot expand menu (outdated version of cus-edit.el)")))
2570 2434
2435
2436;;; Misc
2437
2571(defun reftex-show-commentary () 2438(defun reftex-show-commentary ()
2572 "Use the finder to view the file documentation from `reftex.el'." 2439 "Use the finder to view the file documentation from `reftex.el'."
2573 (interactive) 2440 (interactive)
@@ -2579,6 +2446,36 @@ With optional NODE, go directly to that node."
2579 (interactive) 2446 (interactive)
2580 (info (format "(reftex)%s" (or node "")))) 2447 (info (format "(reftex)%s" (or node ""))))
2581 2448
2449(defun reftex-report-bug ()
2450 "Report a bug in RefTeX.
2451
2452Don't hesitate to report any problems or inaccurate documentation.
2453
2454If you don't have setup sending mail from (X)Emacs, please copy the
2455output buffer into your mail program, as it gives us important
2456information about your RefTeX version and configuration."
2457 (interactive)
2458 (require 'reporter)
2459 (let ((reporter-prompt-for-summary-p "Bug report subject: "))
2460 (reporter-submit-bug-report
2461 "bug-auctex@gnu.org"
2462 reftex-version
2463 (list 'window-system
2464 'reftex-plug-into-AUCTeX)
2465 nil nil
2466 "Remember to cover the basics, that is, what you expected to happen and
2467what in fact did happen.
2468
2469Check if the bug is reproducable with an up-to-date version of
2470RefTeX available from http://www.gnu.org/software/auctex/.
2471
2472If the bug is triggered by a specific \(La\)TeX file, you should try
2473to produce a minimal sample file showing the problem and include it
2474in your report.
2475
2476Your bug report will be posted to the AUCTeX bug reporting list.
2477------------------------------------------------------------------------")))
2478
2582;;; Install the kill-buffer and kill-emacs hooks ------------------------------ 2479;;; Install the kill-buffer and kill-emacs hooks ------------------------------
2583 2480
2584(add-hook 'kill-buffer-hook 'reftex-kill-buffer-hook) 2481(add-hook 'kill-buffer-hook 'reftex-kill-buffer-hook)
@@ -2594,6 +2491,4 @@ With optional NODE, go directly to that node."
2594(setq reftex-tables-dirty t) ; in case this file is evaluated by hand 2491(setq reftex-tables-dirty t) ; in case this file is evaluated by hand
2595(provide 'reftex) 2492(provide 'reftex)
2596 2493
2597;;;============================================================================
2598
2599;;; reftex.el ends here 2494;;; reftex.el ends here