annotate lisp/textmodes/reftex.el @ 23707:b0fe513da546

(reftex-finding-files): Group documentation fixed. (reftex-toc-toggle-file-boundary, reftex-toc-toggle-labels, reftex-toc-toggle-context,reftex-find-start-point): New functions. (reftex-toc-include-labels, reftex-toc-include-context, reftex-toc-include-file-boundaries, reftex-toc-keep-other-windows): New options. (reftex-use-text-after-label-as-context): Option removed. (reftex-extract-bib-entries): Protect use in non-latex buffers. (reftex-toc-visit-location): Renamed from `reftex-toc-visit-line'. (reftex-latin1-to-ascii): Works now with and without Mule. (reftex-truncate): Removed special stuff for Emacs 20.2. (reftex-get-offset): Made more general. (reftex-show-label-location): Renamed from `reftex-select-label-callback'. (reftex-pop-to-label): Function removed (using `reftex-show-label-location' instead. (reftex-insert-docstruct): Renamed from `reftex-make-and-insert-label-list'. Function args changed. (reftex-toc): Now uses `reftex-insert-docstruct' and `reftex-find-start-point'. (reftex-select-item): Use `reftex-find-start-point'. (reftex-toc-visit-line): Can display labels and file boundaries. (reftex-TeX-master-file): `(TeX-master-file)' protected.
author Carsten Dominik <dominik@science.uva.nl>
date Fri, 13 Nov 1998 16:17:25 +0000
parents 608bc56ca20e
children a56b80c4166a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22388
2d0bece94ee7 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 21892
diff changeset
1 ;;; reftex.el --- Minor mode for doing \label, \ref and \cite in LaTeX
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2 ;; Copyright (c) 1997, 1998 Free Software Foundation, Inc.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4 ;; Author: Carsten Dominik <dominik@strw.LeidenUniv.nl>
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Keywords: tex
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; any later version.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; GNU General Public License for more details.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; Boston, MA 02111-1307, USA.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;;---------------------------------------------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 ;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;;; Commentary:
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;;
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
28 ;; RefTeX is a minor mode with distinct support for \ref, \label, and \cite
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
29 ;; commands in (multi-file) LaTeX documents.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
30 ;; - A table of contents provides easy access to any part of a document.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
31 ;; - Labels are created semi-automatically.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
32 ;; - Definition context of labels is provided when creating a reference.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
33 ;; - Citations are simplified with efficient database lookup.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;;
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
35 ;;
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
36 ;; INSTALLATION
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
37 ;; ------------
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
38 ;;
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
39 ;; - If this file is part of an X/Emacs distribution, it is installed.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
40 ;; - For XEmacs 21.x, you need to install the RefTeX plug-in package
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
41 ;; available from the XEmacs distribution sites.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
42 ;; - If you have downloaded this file from the maintainers webpage, follow
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
43 ;; the instructions in the INSTALL file of the distrubution.
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
44 ;;
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
45 ;; To turn RefTeX Mode on and off in a buffer, use `M-x reftex-mode'.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 ;;
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
47 ;; To turn on RefTeX Mode for all LaTeX files, add the following lines
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
48 ;; to your .emacs file:
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 ;;
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
50 ;; (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; AUCTeX LaTeX mode
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
51 ;; (add-hook 'latex-mode-hook 'turn-on-reftex) ; Emacs latex mode
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 ;;
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
53 ;;
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
54 ;; DOCUMENTATION
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
55 ;; -------------
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
56 ;;
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
57 ;; See below for a short summary of how to use RefTeX.
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
58 ;;
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
59 ;; There is an extensive texinfo document describing RefTeX in detail.
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
60 ;; One way to view this documentation is `M-x reftex-info RET'.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
61 ;;
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
62 ;; The documentation in various formats is also available at
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
63 ;;
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
64 ;; http://www.strw.leidenuniv.nl/~dominik/Tools/
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
65 ;;
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
66 ;;---------------------------------------------------------------------------
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
67 ;;
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
68 ;; RefTeX in a Nutshell
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
69 ;; ====================
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
70 ;;
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
71 ;; 1. Table of Contents
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
72 ;; Typing `C-c =' (`reftex-toc') will show a table of contents of the
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
73 ;; document. From that buffer, you can jump quickly to every part of
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
74 ;; your document. Press `?' to get help.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
75 ;;
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
76 ;; 2. Labels and References
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
77 ;; RefTeX distinguishes labels for different environments. It knows
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
78 ;; about all standard environments (and many others), and can be
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
79 ;; configured to recognize any additional labeled environments you
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
80 ;; have defined yourself (variable REFTEX-LABEL-ALIST).
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
81 ;;
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
82 ;; * Creating Labels
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
83 ;; Type `C-c (' (`reftex-label') to insert a label at point. RefTeX
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
84 ;; will either
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
85 ;; - derive a label from context (default for section labels)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
86 ;; - prompt for a label string (default for figures and tables) or
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
87 ;; - insert a simple label made of a prefix and a number (all other
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
88 ;; environments)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
89 ;;
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
90 ;; Which labels are created how is configurable with the variable
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
91 ;; REFTEX-INSERT-LABEL-FLAGS.
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
92 ;;
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
93 ;; * Referencing Labels
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
94 ;; To make a reference, type `C-c )' (`reftex-reference'). This
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
95 ;; shows an outline of the document with all labels of a certain type
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
96 ;; (figure, equation,...) and some label context. Selecting a label
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
97 ;; inserts a `\ref{LABEL}' macro into the original buffer.
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
98 ;;
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
99 ;; 3. Citations
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
100 ;; Typing `C-c [' (`reftex-citation') will let you specify a regular
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
101 ;; expression to search in current BibTeX database files (as
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
102 ;; specified in the `\bibliography' command) and pull out a list of
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
103 ;; matches for you to choose from. The list is *formatted* and
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
104 ;; sorted. The selected article is referenced as `\cite{KEY}' (see
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
105 ;; also the variable REFTEX-CITE-FORMAT).
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
106 ;;
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
107 ;; 4. Viewing Cross References
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
108 ;; When point is idle on the argument of a `\ref' or `\cite' macro,
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
109 ;; the echo area will (if it is empty) display information about the
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
110 ;; citation/cross reference. Press `C-c &' (`reftex-view-crossref'),
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
111 ;; or click with `S-mouse-2' on the macro argument to display the
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
112 ;; corresponding label definition or BibTeX database entry in another
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
113 ;; window.
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
114 ;;
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
115 ;; 5. Multifile Documents
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
116 ;; Multifile Documents are fully supported. RefTeX provides cross
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
117 ;; referencing information from all files which are part of the
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
118 ;; document, and across document borders (`xr.sty').
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
119 ;;
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
120 ;; 6. Document Parsing
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
121 ;; RefTeX needs to parse the document in order to find labels and
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
122 ;; other information. It does it automatically once and updates its
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
123 ;; list internally when `reftex-label' is used. To enforce
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
124 ;; reparsing, call any of the commands described above with a raw
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
125 ;; `C-u' prefix, or press the `r' key in the label selection buffer
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
126 ;; or the table of contents buffer.
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
127 ;;
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
128 ;; 7. Useful Settings
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
129 ;; To make RefTeX faster for large documents, and to integrate with
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
130 ;; AUCTeX, try these:
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
131 ;; (setq reftex-enable-partial-scans t)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
132 ;; (setq reftex-save-parse-info t)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
133 ;; (setq reftex-use-multiple-selection-buffers t)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
134 ;; (setq reftex-plug-into-AUCTeX t)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 ;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 ;;---------------------------------------------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 ;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 ;; AUTHOR
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
139 ;; ======
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 ;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 ;; Carsten Dominik <dominik@strw.LeidenUniv.nl>
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 ;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 ;; with contributions from Stephen Eglen
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 ;;
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
145 ;; RefTeX is bundled with Emacs and available as a plug-in package for
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
146 ;; XEmacs 21.x. If you need to install it yourself, you can find a
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
147 ;; distribution at
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 ;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 ;; http://www.strw.leidenuniv.nl/~dominik/Tools/
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
150 ;;
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 ;; THANKS TO:
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 ;; ---------
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
153 ;; Thanks to the people on the Net who have used RefTeX and helped
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
154 ;; developing it with their reports. In particular thanks to
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 ;;
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
156 ;; Fran Burstall, Alastair Burt, Soren Dayton, Stephen Eglen,
23344
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
157 ;; Karl Eichwalder, Peter Galbraith, Dieter Kraft, Kai Grossjohann,
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
158 ;; Adrian Lanz, Rory Molinari, Laurent Mugnier, Sudeep Kumar Palat,
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
159 ;; Daniel Polani, Robin Socha, Richard Stanton, Allan Strand,
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
160 ;; Jan Vroonhof, Christoph Wedler, Alan Williams.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 ;;
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
162 ;; Finally thanks to Uwe Bolick who first got me (some years ago) into
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
163 ;; supporting LaTeX labels and references with an editor (which was
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
164 ;; MicroEmacs at the time).
18219
aaeaae005e98 Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents: 18123
diff changeset
165 ;;
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
166 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
167 ;;
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
168 ;;;;;;
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 ;;; Code:
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
172 (eval-when-compile (require 'cl))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
173
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 ;; Stuff that needs to be there when we use defcustom
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 (require 'custom)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 (defvar reftex-tables-dirty t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 "Flag showing if tables need to be re-computed.")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 (eval-and-compile
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 (defun reftex-set-dirty (symbol value)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 (setq reftex-tables-dirty t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 (set symbol value)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
185 ;;; ======================================================================
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
186 ;;;
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
187 ;;; Configuration Section
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
189 ;; Define the two constants which are needed during compilation
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
190
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
191 (eval-and-compile
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
192 (defconst reftex-label-alist-builtin
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
193 '(
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
194 ;; Some aliases, mostly for backward compatibility
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
195 (Sideways "Alias for -->rotating" (rotating))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
196 (AMSTeX "amsmath with eqref macro"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
197 ((nil ?e nil "~\\eqref{%s}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
198 amsmath))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
199
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
200 ;; Individual package defaults
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
201 (amsmath "AMS-LaTeX math environments"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
202 (("align" ?e nil nil eqnarray-like)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
203 ("gather" ?e nil nil eqnarray-like)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
204 ("multline" ?e nil nil t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
205 ("flalign" ?e nil nil eqnarray-like)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
206 ("alignat" ?e nil nil alignat-like)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
207 ("xalignat" ?e nil nil alignat-like)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
208 ("xxalignat" ?e nil nil alignat-like)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
209 ("subequations" ?e nil nil t)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
210
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
211 (endnotes "The \\endnote macro"
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
212 (("\\endnote[]{}" ?n nil nil 2 (regexp "Endnotes?"))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
213
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
214 (fancybox "The Beqnarray environment"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
215 (("Beqnarray" ?e nil nil eqnarray-like)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
216
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
217 (floatfig "The floatingfigure environment"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
218 (("floatingfigure" ?f nil nil caption)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
219
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
220 (longtable "The longtable environment"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
221 (("longtable" ?t nil nil caption)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
222
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
223 (picinpar "The figwindow and tabwindow environments"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
224 (("figwindow" ?f nil nil 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
225 ("tabwindow" ?f nil nil 1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
226
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
227 (rotating "Sidewaysfigure and table"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
228 (("sidewaysfigure" ?f nil nil caption)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
229 ("sidewaystable" ?t nil nil caption)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
230
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
231 (sidecap "CSfigure and SCtable"
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
232 (("SCfigure" ?f nil nil caption)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
233 ("SCtable" ?t nil nil caption)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
234
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
235 (subfigure "Subfigure environments/macro"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
236 (("subfigure" ?f nil nil caption)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
237 ("subfigure*" ?f nil nil caption)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
238 ("\\subfigure[]{}" ?f nil nil 1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
239
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
240 (supertab "Supertabular environment"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
241 (("supertabular" ?t nil nil "\\tablecaption{")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
242
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
243 (wrapfig "The wrapfigure environment"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
244 (("wrapfigure" ?f nil nil caption)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
245
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
246 ;; The LaTeX core stuff
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
247 (LaTeX "LaTeX default environments"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
248 (("section" ?s "sec:" "~\\ref{%s}" (nil . t)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
249 (regexp "parts?" "chapters?" "chap\\." "sections?" "sect?\\."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
250 "paragraphs?" "par\\."
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
251 "\\\\S" "\247" "Teile?" "Kapitel" "Kap\\." "Abschnitte?"
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
252 "appendi\\(x\\|ces\\)" "App\\." "Anh\"?ange?" "Anh\\."))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
253
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
254 ("enumerate" ?i "item:" "~\\ref{%s}" item
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
255 (regexp "items?" "Punkte?"))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
256
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
257 ("equation" ?e "eq:" "~(\\ref{%s})" t
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
258 (regexp "equations?" "eqs?\\." "eqn\\." "Gleichung\\(en\\)?" "Gl\\."))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
259 ("eqnarray" ?e "eq:" nil eqnarray-like)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
260
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
261 ("figure" ?f "fig:" "~\\ref{%s}" caption
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
262 (regexp "figure?[sn]?" "figs?\\." "Abbildung\\(en\\)?" "Abb\\."))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
263 ("figure*" ?f nil nil caption)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
264
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
265 ("table" ?t "tab:" "~\\ref{%s}" caption
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
266 (regexp "tables?" "tab\\." "Tabellen?"))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
267 ("table*" ?t nil nil caption)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
268
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
269 ("\\footnote[]{}" ?n "note:" "~\\ref{%s}" 2
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
270 (regexp "footnotes?" "notes?" "Anmerkung\\(en\\)?" "Anm\\."))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
271
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
272 ("any" ?\ " " "~\\ref{%s}" nil)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
273
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
274 ;; The label macro is hard coded, but it *could* be defined like this:
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
275 ;;("\\label{*}" nil nil nil nil)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
276 ))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
277
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
278 )
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
279 "The default label environment descriptions.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
280 Lower-case symbols correspond to a style file of the same name in the LaTeX
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
281 distribution. Mixed-case symbols are convenience aliases.")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
282
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
283 (defconst reftex-cite-format-builtin
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
284 '((default "Default macro \\cite{%l}"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
285 "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
286 (natbib "The Natbib package"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
287 ((?\C-m . "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
288 (?t . "\\citet{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
289 (?T . "\\citet*{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
290 (?p . "\\citep{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
291 (?P . "\\citep*{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
292 (?e . "\\citep[e.g.][]{%l}")
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
293 (?s . "\\citep[see][]{%l}")
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
294 (?a . "\\citeauthor{%l}")
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
295 (?A . "\\citeauthor*{%l}")
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
296 (?y . "\\citeyear{%l}")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
297 (harvard "The Harvard package"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
298 ((?\C-m . "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
299 (?p . "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
300 (?t . "\\citeasnoun{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
301 (?n . "\\citeasnoun{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
302 (?s . "\\possessivecite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
303 (?e . "\\citeaffixed{%l}{?}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
304 (?y . "\\citeyear{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
305 (?a . "\\citename{%l}")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
306 (chicago "The Chicago package"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
307 ((?\C-m . "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
308 (?t . "\\citeN{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
309 (?T . "\\shortciteN{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
310 (?p . "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
311 (?P . "\\shortcite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
312 (?a . "\\citeA{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
313 (?A . "\\shortciteA{%l}")
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
314 (?y . "\\citeyear{%l}")))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
315 (astron "The Astron package"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
316 ((?\C-m . "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
317 (?p . "\\cite{%l}" )
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
318 (?t . "%2a (\\cite{%l})")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
319 (author-year "Do-it-yourself Author-year"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
320 ((?\C-m . "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
321 (?t . "%2a (%y)\\nocite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
322 (?p . "(%2a %y\\nocite{%l})")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
323 (locally "Full info in parenthesis"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
324 "(%2a %y, %j %v, %P, %e: %b, %u, %s %<)")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
325 )
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
326 "Builtin versions of the citation format.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
327 The following conventions are valid for all alist entries:
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
328 `?\C-m' should always point to a straight \\cite{%l} macro.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
329 `?t' should point to a textual citation (citation as a noun).
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
330 `?p' should point to a parenthetical citation.")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
331 )
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
332
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 ;; Configuration Variables and User Options for RefTeX ------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 (defgroup reftex nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 "LaTeX label and citation support."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 :tag "RefTeX"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
338 :link '(url-link :tag "Home Page"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
339 "http://strw.leidenuniv.nl/~dominik/Tools/")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
340 :link '(emacs-commentary-link :tag "Commentary in reftex.el" "reftex.el")
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
341 :link '(custom-manual "(reftex)Top")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 :prefix "reftex-"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 :group 'tex)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
345 ;; Table of contents configuration --------------------------------------
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
346
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
347 (defgroup reftex-table-of-contents-browser nil
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
348 "A multifile table of contents browser."
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
349 :group 'reftex)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
350
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
351 (defcustom reftex-toc-keep-other-windows t
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
352 "*Non-nil means, split the selected window to display the *toc* buffer.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
353 This helps to keep the window configuration, but makes the *toc* small.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
354 When nil, all other windows except the selected one will be deleted, so
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
355 that the *toc* window fills half the frame."
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
356 :group 'reftex-table-of-contents-browser
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
357 :type 'boolean)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
358
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
359 (defcustom reftex-toc-include-labels nil
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
360 "*Non-nil means, include labels in *toc* buffer.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
361 This flag can be toggled from within the *toc* buffer with the `l' key."
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
362 :group 'reftex-table-of-contents-browser
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
363 :type 'boolean)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
364
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
365 (defcustom reftex-toc-include-context nil
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
366 "*Non-nil means, include context with labels in the *toc* buffer.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
367 Context will only be shown when labels are visible as well.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
368 This flag can be toggled from within the *toc* buffer with the `c' key."
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
369 :group 'reftex-table-of-contents-browser
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
370 :type 'boolean)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
371
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
372 (defcustom reftex-toc-include-file-boundaries nil
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
373 "*Non-nil means, include file boundaries in *toc* buffer.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
374 This flag can be toggled from within the *toc* buffer with the `i' key."
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
375 :group 'reftex-table-of-contents-browser
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
376 :type 'boolean)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
377
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
378 (defcustom reftex-toc-follow-mode nil
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
379 "*Non-nil means, point in *toc* buffer will cause other window to follow.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
380 The other window will show the corresponding part of the document.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
381 This flag can be toggled from within the *toc* buffer with the `f' key."
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
382 :group 'reftex-table-of-contents-browser
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
383 :type 'boolean)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
384
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
385 (defcustom reftex-revisit-to-follow nil
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
386 "*Non-nil means, follow-mode will revisit files if necessary.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
387 When nil, follow-mode will be suspended for stuff in unvisited files."
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
388 :group 'reftex-table-of-contents-browser
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
389 :group 'reftex-referencing-labels
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
390 :type 'boolean)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
391
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
392 (defcustom reftex-toc-mode-hook nil
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
393 "Mode hook for reftex-toc-mode."
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
394 :group 'reftex-table-of-contents-browser
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
395 :type 'hook)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
396
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
397 ;; Label configuration -----------------------------------------------------
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
398
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399 (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
400 "Support for creation, insertion and referencing of labels in LaTeX."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 :group 'reftex)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 (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
404 "Definition of environments and macros to do with label."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 :group 'reftex-label-support)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
407 (defcustom reftex-default-label-alist-entries
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
408 '(amsmath endnotes fancybox floatfig longtable picinpar
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
409 rotating sidecap subfigure supertab wrapfig LaTeX)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
410 "Default label alist specifications. LaTeX should be the last entry.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
411 This list describes the default label environments RefTeX should always use.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
412 It is probably a mistake to remove the LaTeX symbol from this list.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
413
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
414 The options include:
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
415 LaTeX The standard LaTeX environments.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
416 Sideways The sidewaysfigure and sidewaystable environments.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
417 AMSTeX The math environments in the AMS-LaTeX amsmath package.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
418
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
419 For the full list of options, try
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
420
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
421 M-x customize-variable RET reftex-default-label-alist-entries RET."
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
422 :group 'reftex-defining-label-environments
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
423 :set 'reftex-set-dirty
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
424 :type `(set
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
425 :indent 4
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
426 :inline t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
427 :greedy t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
428 ,@(mapcar
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
429 (function
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
430 (lambda (x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
431 (list 'const ':tag (concat (symbol-name (nth 0 x))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
432 ": " (nth 1 x))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
433 (nth 0 x))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
434 reftex-label-alist-builtin)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
435
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 (defcustom reftex-label-alist nil
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
437 "Alist with information on environments for \\label-\\ref use.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
438
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
439 This docstring is easier to understand after reading the configuration
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
440 examples in `reftex.el'. Looking at the builtin defaults in the constant
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
441 `reftex-label-alist-builtin' may also be instructive.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
442
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
443 Set this variable to define additions and changes to the default. The only
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
444 things you MUST NOT change is that `?s' is the type indicator for section
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
445 labels, and SPC for the `any' label type. These are hard-coded at other
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
446 places in the code.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
447
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
448 Each list entry describes either an environment carrying a counter for use
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
449 with \\label and \\ref, or a LaTeX macro defining a label as (or inside)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
450 one of its arguments. The elements of each list entry are:
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
451
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452 0. Name of the environment (like \"table\") or macro (like \"\\\\myfig\").
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
453 For macros, indicate the macro arguments for best results, as in
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
454 \"\\\\myfig[]{}{}{*}{}\". Use square brackets for optional arguments,
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
455 a star to mark the label argument, if any. The macro does not have to
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
456 have a label argument - you could also use \\label{..} inside one of
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
457 its arguments.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458 Special names: `section' for section labels, `any' to define a group
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459 which contains all labels.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
460 This may also be nil if the entry is only meant to change some settings
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 associated with the type indicator character (see below).
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
463 1. Type indicator character, like `?t', must be a printable ASCII character.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
464 The type indicator is a single character which defines a label type.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
465 Any label inside the environment or macro is assumed to belong to this
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
466 type. The same character may occur several times in this list, to cover
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
467 cases in which different environments carry the same label type (like
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
468 `equation' and `eqnarray').
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
469 If the type indicator is nil and the macro has a label argument {*},
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
470 the macro defines neutral labels just like \label. In this case
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
471 the reminder of this entry is ignored.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473 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
474 The prefix is a short string used as the start of a label. It may be the
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
475 empty string. The prefix may contain the following `%' escapes:
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
476 %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
477 %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
478 %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
479
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
480 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
481
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
482 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
483 the label.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
484 When the format starts with `~', the `~' will only be inserted if
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
485 there is not already a whitespace before point.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487 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
488 - 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
489 - If t, use
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490 - the section heading for section labels.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
491 - text following the \\begin{...} statement of environments.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
492 (not a good choice for environments like eqnarray or enumerate,
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
493 where one has several labels in a single environment).
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
494 - text after the macro name (starting with the first arg) for macros.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
495 - If an integer, use the nth argument of the macro. As a special case,
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
496 1000 means to get text after the last macro argument.
18220
36a61aa59b9d (tex-main-file, outline-minor-mode): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents: 18219
diff changeset
497 - 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
498 is then the text following the end of the match. E.g. putting this to
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
499 \"\\\\\\\\caption[[{]\" will use the caption in a figure or table
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
500 environment.
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
501 \"\\\\\\\\begin{eqnarray}\\\\|\\\\\\\\\\\\\\\\\" works for eqnarrays.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
502 - If any of `caption', `item', `eqnarray-like', `alignat-like', this
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
503 symbol will internally be translated into an appropriate regexp
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
504 (see also the variable `reftex-default-context-regexps').
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505 - 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
506 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
507 function is expected to return a suitable context string. It should
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 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
509 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
510 the label macro as context:
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 (defun my-context-function (env-or-mac)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 (if (> (point-max) (+ 10 (point)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 (buffer-substring (point) (+ 10 (point)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 (error \"Buffer too small\")))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
517 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
518 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
519 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
520 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
521 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
522 actually used for section labels.
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
523
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
524 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
525 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
526 `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
527 restricted to labels of the correct type.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
528 If the first element of this wordlist is the symbol `regexp', the
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
529 strings are interpreted as regular expressions. RefTeX will add
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
530 a \"\\\\W\" to the beginning and other stuff to the end of the regexp.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532 If the type indicator characters of two or more entries are the same, RefTeX
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533 will use
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534 - the first non-nil format and prefix
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 - the magic words of all involved entries.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536
18220
36a61aa59b9d (tex-main-file, outline-minor-mode): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents: 18219
diff changeset
537 Any list entry may also be a symbol. If that has an association in
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
538 `reftex-label-alist-builtin', the cddr of that association is spliced into the
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
539 list. However, builtin defaults should normally be set with the variable
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
540 `reftex-default-label-alist-entries."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
541 :group 'reftex-defining-label-environments
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542 :set 'reftex-set-dirty
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
543 :type
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
544 `(repeat
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
545 (choice :tag "Package or Detailed "
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
546 :value ("" ?a nil nil nil nil)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
547 (list :tag "Detailed Entry"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
548 :value ("" ?a nil nil nil nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
549 (choice :tag "Environment or \\macro "
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
550 (const :tag "Ignore, just use typekey" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
551 (string ""))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
552 (choice :tag "Type specification "
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
553 (const :tag "unspecified, like in \\label" nil)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
554 (character :tag "Char " ?a))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
555 (choice :tag "Label prefix string "
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
556 (const :tag "Default" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
557 (string :tag "String" "lab:"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
558 (choice :tag "Label reference format"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
559 (const :tag "Default" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
560 (string :tag "String" "~\\ref{%s}"))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
561 (choice :tag "Context method "
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
562 (const :tag "Default position" t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
563 (const :tag "After label" nil)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
564 (number :tag "Macro arg nr" 1)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
565 (regexp :tag "Regexp" "")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
566 (const :tag "Caption in float" caption)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
567 (const :tag "Item in list" item)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
568 (const :tag "Eqnarray-like" eqnarray-like)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
569 (const :tag "Alignat-like" alignat-like)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
570 (symbol :tag "Function" my-func))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
571 (repeat :tag "Magic words" :extra-offset 2 (string)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
572 (choice
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
573 :tag "Package"
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
574 :value AMSTeX
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
575 ,@(mapcar
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
576 (function
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
577 (lambda (x)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
578 (list 'const ':tag (concat (symbol-name (nth 0 x)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
579 (nth 0 x))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
580 reftex-label-alist-builtin)))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
582 ;; LaTeX section commands and level numbers
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
583 (defcustom reftex-section-levels
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
584 '(
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
585 ("part" . 0)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
586 ("chapter" . 1)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
587 ("section" . 2)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
588 ("subsection" . 3)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
589 ("subsubsection" . 4)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
590 ("paragraph" . 5)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
591 ("subparagraph" . 6)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
592 ("subsubparagraph" . 7)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
593 )
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
594 "Commands and levels used for defining sections in the document.
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
595 The car of each cons cell is the name of the section macro. The cdr is a
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
596 number indicating its level."
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
597 :group 'reftex-defining-label-environments
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
598 :set 'reftex-set-dirty
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
599 :type '(repeat
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
600 (cons (string :tag "sectioning macro" "")
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
601 (number :tag "level " 0))))
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
602
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
603 (defcustom reftex-default-context-regexps
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
604 '((caption . "\\\\\\(rot\\)?caption\\*?[[{]")
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
605 (item . "\\\\item\\(\\[[^]]*\\]\\)?")
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
606 (eqnarray-like . "\\\\begin{%s}\\|\\\\\\\\")
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
607 (alignat-like . "\\\\begin{%s}{[0-9]*}\\|\\\\\\\\"))
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
608 "Alist with default regular expressions for finding context.
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
609 The form (format regexp (regexp-quote environment)) is used to calculate
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
610 the final regular expression - so %s will be replaced with the environment
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
611 or macro."
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
612 :group 'reftex-defining-label-environments
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
613 :type '(repeat (cons (symbol) (regexp))))
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
614
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
615 ;; Label insertion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
616
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
617 (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
618 "Options on how to create new labels."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
619 :group 'reftex-label-support)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
620
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
621 (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
622 "Flags governing label insertion. First flag DERIVE, second flag PROMPT.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
623
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
624 If DERIVE is t, RefTeX will try to derive a sensible label from context.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
625 A section label for example will be derived from the section heading.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
626 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
627 specifications given in `reftex-derive-label-parameters'.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
628 If RefTeX fails to derive a label, it will prompt the user.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
629 If DERIVE is nil, the label generated will consist of the prefix and a
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
630 unique number, like `eq:23'.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
631
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
632 If PROMPT is t, the user will be prompted for a label string. The prompt will
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
633 already contain the prefix, and (if DERIVE is t) a default label derived from
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
634 context. When PROMPT is nil, the default label will be inserted without
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
635 query.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
636
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
637 So the combination of DERIVE and PROMPT controls label insertion. Here is a
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
638 table describing all four possibilities:
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
639
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
640 DERIVE PROMPT ACTION
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
641 -------------------------------------------------------------------------
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
642 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
643 nil t Prompt for label.
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
644 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
645 t t Derive a label from context and prompt for confirmation.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
646
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
647 Each flag may be set to t, nil, or a string of label type letters
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
648 indicating the label types for which it should be true. The strings work
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
649 like character classes.
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
650 Thus, the combination may be set differently for each label type. The
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
651 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
652 (with confirmation). Prompt for figure and table labels. Use simple labels
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
653 without confirmation for everything else.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
654 The available label types are: s (section), f (figure), t (table), i (item),
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
655 e (equation), n (footnote), plus any definitions in `reftex-label-alist'."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
656 :group 'reftex-making-and-inserting-labels
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
657 :type '(list (choice :tag "Derive label from context"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
658 (const :tag "always" t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
659 (const :tag "never" nil)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
660 (string :tag "selected label types" ""))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
661 (choice :tag "Prompt for label string "
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
662 :entry-format " %b %v"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
663 (const :tag "always" t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
664 (const :tag "never" nil)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
665 (string :tag "selected label types" ""))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
667 (defcustom reftex-string-to-label-function 'reftex-string-to-label
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
668 "Function to turn an arbitrary string into a legal label.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
669 RefTeX's default function uses the variable `reftex-derive-label-parameters'."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
670 :group 'reftex-making-and-inserting-labels
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
671 :type 'symbol)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
672
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
673 (defcustom reftex-translate-to-ascii-function 'reftex-latin1-to-ascii
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
674 "Filter function which will process a context string before it is used
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
675 to derive a label from it. The intended application is to convert ISO or
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
676 Mule characters into something legal in labels. The default function
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
677 removes the accents from Latin-1 characters. X-Symbol (>=2.6) sets this
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
678 variable to the much more general `x-symbol-translate-to-ascii'."
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
679 :group 'reftex-making-and-inserting-labels
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
680 :type 'symbol)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
681
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
682 (defcustom reftex-derive-label-parameters '(3 20 t 1 "-"
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
683 ("the" "on" "in" "off" "a" "for" "by" "of" "and" "is" "to") t)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
684 "Parameters for converting a string into a label.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
685 NWORDS Number of words to use.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
686 MAXCHAR Maximum number of characters in a label string.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
687 ILLEGAL nil: Throw away any words containing characters illegal in labels.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
688 t: Throw away only the illegal characters, not the whole word.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
689 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
690 t: Always abbreviate words (see `reftex-abbrev-parameters').
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
691 not t and not nil: Abbreviate words if necessary to shorten
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
692 label string below MAXCHAR.
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
693 SEPARATOR String separating different words in the label.
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
694 IGNOREWORDS List of words which should not be part of labels.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
695 DOWNCASE t: Downcase words before using them."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
696 :group 'reftex-making-and-inserting-labels
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
697 :type '(list (integer :tag "Number of words " 3)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
698 (integer :tag "Maximum label length " 20)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
699 (choice :tag "Illegal characters in words"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
700 (const :tag "throw away entire word" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
701 (const :tag "throw away single chars" t))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
702 (choice :tag "Abbreviate words "
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
703 (const :tag "never" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
704 (const :tag "always" t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
705 (const :tag "when label is too long" 1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
706 (string :tag "Separator between words " "-")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
707 (repeat :tag "Ignore words"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
708 :entry-format " %i %d %v"
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
709 (string :tag ""))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
710 (option (boolean :tag "Downcase words "))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
711
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
712 (defcustom reftex-label-illegal-re "[^-a-zA-Z0-9_+=:;,.]"
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
713 "Regexp matching characters not legal in labels."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
714 :group 'reftex-making-and-inserting-labels
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
715 :type '(regexp :tag "Regular Expression"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
716
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
717 (defcustom reftex-abbrev-parameters '(4 2 "^aeiou" "aeiou")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
718 "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
719 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
720 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
721 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
722 AFTER Character class after abbrev point in word."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
723 :group 'reftex-making-and-inserting-labels
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
724 :type '(list
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
725 (integer :tag "Minimum chars per word" 4)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
726 (integer :tag "Shorten by at least " 2)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
727 (string :tag "cut before char class " "^saeiou")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
728 (string :tag "cut after char class " "aeiou")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
729
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
730 (defcustom reftex-format-label-function nil
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
731 "Function which produces the string to insert as a label definition.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
732 Normally should be nil, unless you want to do something fancy.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
733 The function will be called with two arguments, the LABEL and the DEFAULT
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
734 FORMAT, which usually is `\label{%s}'. The function should return the
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
735 string to insert into the buffer."
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
736 :group 'reftex-making-and-inserting-labels
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
737 :type 'function)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
738
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
739 ;; Label referencing
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
740
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
741 (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
742 "Options on how to reference labels."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
743 :group 'reftex-label-support)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
744
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
745 (eval-and-compile
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
746 (defconst reftex-tmp
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
747 '((const :tag "on" t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
748 (const :tag "off" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
749 (string :tag "Selected label types"))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
750
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
751 (defcustom reftex-label-menu-flags '(t t nil nil nil nil t nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
752 "List of flags governing the label menu makeup.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
753 The flags are:
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
754
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
755 TABLE-OF-CONTENTS Show the labels embedded in a table of context.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
756 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
757 COUNTERS Show counters. This just numbers the labels in the menu.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
758 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
759 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
760 SHOW-COMMENTED Show labels from regions which are commented out.
21115
fea2f6a2818d 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21114
diff changeset
761 MATCH-IN-TOC Obsolete flag.
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
762 SHOW FILES Show begin and end of included files.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
763
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
764 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
765 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
766 like character classes in regular expressions. Thus, setting one of the
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
767 flags to \"sf\" makes the flag true for section and figure labels, nil
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
768 for everything else. Setting it to \"^sf\" makes it the other way round.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
769 The available label types are: s (section), f (figure), t (table), i (item),
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
770 e (equation), n (footnote), plus any definitions in `reftex-label-alist'.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
771
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
772 Most options can also be switched from the label menu itself - so if you
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
773 decide here to not have a table of contents in the label menu, you can still
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
774 get one interactively during selection from the label menu."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
775 :group 'reftex-referencing-labels
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
776 :type
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
777 `(list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
778 (choice :tag "Embed in table of contents " ,@reftex-tmp)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
779 (choice :tag "Show section numbers " ,@reftex-tmp)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
780 (choice :tag "Show individual counters " ,@reftex-tmp)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
781 (choice :tag "Hide short context " ,@reftex-tmp)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
782 (choice :tag "Follow context in other window " ,@reftex-tmp)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
783 (choice :tag "Show commented labels " ,@reftex-tmp)
21115
fea2f6a2818d 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21114
diff changeset
784 (choice :tag "Obsolete flag, Don't use. " ,@reftex-tmp)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
785 (choice :tag "Show begin/end of included files" ,@reftex-tmp)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
786
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
787 (defcustom reftex-vref-is-default nil
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
788 "*Non-nil means, the varioref macro \\vref is used as default.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
789 In the selection buffer, the `v' key toggles the reference macro between
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
790 `\\ref' and `\\vref'. The value of this variable determines the default
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
791 which is active when entering the selection process.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
792 Instead of nil or t, this may also be a string of type letters indicating
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
793 the label types for which it should be true."
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
794 :group 'reftex-referencing-labels
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
795 :type `(choice :tag "\\vref is default macro" ,@reftex-tmp))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
796
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
797 (defcustom reftex-level-indent 2
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
798 "*Number of spaces to be used for indentation per section level."
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
799 :group 'reftex-referencing-labels
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
800 :type 'integer)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
801
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
802 (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
803 "*Non-nil means, `reftex-reference' will try to guess the label type.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
804 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
805 the words given in `reftex-label-alist'. When it finds a match, RefTeX will
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
806 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
807 a label type. If you set this variable to nil, RefTeX will always prompt."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
808 :group 'reftex-referencing-labels
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
809 :type 'boolean)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
810
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
811 (defcustom reftex-format-ref-function nil
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
812 "Function which produces the string to insert as a reference.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
813 Normally should be nil, because the format to insert a reference can
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
814 already be specified in `reftex-label-alist'.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
815 The function will be called with two arguments, the LABEL and the DEFAULT
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
816 FORMAT, which normally is `~\ref{%s}'. The function should return the
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
817 string to insert into the buffer."
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
818 :group 'reftex-referencing-labels
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
819 :type 'function)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
820
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
821 (defcustom reftex-select-label-mode-hook nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
822 "Mode hook for reftex-select-label-mode."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
823 :group 'reftex-referencing-labels
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
824 :type 'hook)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
825
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
826 ;; BibteX citation configuration ----------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
827
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
828 (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
829 "Support for referencing bibliographic data with BibTeX."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
830 :group 'reftex)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
831
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
832 (defvar reftex-bibfile-ignore-list nil) ; compatibility
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
833 (defcustom reftex-bibfile-ignore-regexps nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
834 "*List of regular expressions to exclude files in \\bibliography{..}.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
835 File names matched by these regexps will not be parsed by RefTeX.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
836 Intended for files which contain only `@string' macro definitions and the
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
837 like, which are ignored by RefTeX anyway."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
838 :group 'reftex-citation-support
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
839 :set 'reftex-set-dirty
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
840 :type '(repeat (regexp)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
841
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
842 (defcustom reftex-default-bibliography nil
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
843 "*List of BibTeX database files which should be used if none are specified.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
844 When `reftex-citation' is called from a document which has neither a
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
845 `\bibliography{..}' statement nor a `thebibliography' environment,
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
846 RefTeX will scan these files instead. Intended for using
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
847 `reftex-citation' in non-LaTeX files."
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
848 :group 'reftex-citation-support
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
849 :type '(repeat (file)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
850
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
851 (defcustom reftex-sort-bibtex-matches 'reverse-year
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
852 "*Sorting of the entries found in BibTeX databases by reftex-citation.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
853 Possible values:
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
854 nil Do not sort entries.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
855 'author Sort entries by author name.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
856 'year Sort entries by increasing year.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
857 'reverse-year Sort entries by decreasing year."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
858 :group 'reftex-citation-support
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
859 :type '(choice (const :tag "not" nil)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
860 (const :tag "by author" author)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
861 (const :tag "by year" year)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
862 (const :tag "by year, reversed" reverse-year)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
863
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
864 (defcustom reftex-cite-format 'default
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
865 "*The format of citations to be inserted into the buffer.
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
866 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
867 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
868 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
869
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
870 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
871 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
872
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
873 %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
874 %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
875 %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
876 %A First author name only.
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
877 %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
878
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
879 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
880 %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
881 %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
882 %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
883 %r address %s school %u publisher %t title
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
884 %v volume %y year
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
885 %B booktitle, abbreviated %T title, abbreviated
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
886
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
887 Usually, only %l is needed. The other stuff is mainly for the echo area
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
888 display, and for (setq reftex-comment-citations t).
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
889
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
890 %< as a special operator kills punctuation and space around it after the
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
891 string has been formatted.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
892
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
893 Beware that all this only works with BibTeX database files. When
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
894 citations are made from the \\bibitems in an explicit thebibliography
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
895 environment, only %l is available.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
896
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
897 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
898 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
899 strings.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
900 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
901 `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
902 the predefined styles (see `reftex-cite-format-builtin'). E.g.:
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
903 (setq reftex-cite-format 'natbib)"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
904 :group 'reftex-citation-support
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
905 :type
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
906 `(choice
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
907 :format "%{%t%}: \n%[Value Menu%] %v"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
908 (radio :tag "Symbolic Builtins"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
909 :indent 4
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
910 :value default
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
911 ,@(mapcar
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
912 (function
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
913 (lambda (x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
914 (list 'const ':tag (concat (symbol-name (nth 0 x))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
915 ": " (nth 1 x))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
916 (nth 0 x))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
917 reftex-cite-format-builtin))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
918 (string :tag "format string" "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
919 (repeat :tag "key-ed format strings"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
920 :value ((?\r . "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
921 (?t . "\\cite{%l}") (?p . "\\cite{%l}"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
922 (cons (character :tag "Key character" ?\r)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
923 (string :tag "Format string" "")))))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
924
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
925 (defcustom reftex-comment-citations nil
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
926 "*Non-nil means add a comment for each citation describing the full entry.
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
927 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
928 :group 'reftex-citation-support
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
929 :type 'boolean)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
930
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
931 (defcustom reftex-cite-comment-format
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
932 "%% %2a %y, %j %v, %P, %b, %e, %u, %s %<\n"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
933 "Citation format used for commented citations. Must NOT contain %l.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
934 See the variable `reftex-cite-format' for possible percent escapes."
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
935 :group 'reftex-citation-support
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
936 :type 'string)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
937
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
938 (defcustom reftex-cite-view-format
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
939 "%2a %y, %T, %B, %j %v:%P, %s %<"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
940 "Citation format used to display citation info in the message area.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
941 Must NOT contain %l. See the variable `reftex-cite-format' for
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
942 possible percent escapes."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
943 :group 'reftex-citation-support
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
944 :group 'reftex-viewing-cross-references-and-citations
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
945 :type 'string)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
946
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
947 (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
948 "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
949 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
950 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
951 2. final names separator, like \" and \" in Jones, Brown and Miller
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
952 3. The \"et al\" string, like \" {\\it et al.}\" in Jones {\\it et al.}"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
953 :group 'reftex-citation-support
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
954 :type '(list
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
955 (string :tag "Separator for names ")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
956 (string :tag "Separator for last name in list")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
957 (string :tag "string used as et al. ")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
958
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
959 (defcustom reftex-format-cite-function nil
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
960 "Function which produces the string to insert as a citation.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
961 Normally should be nil, because the format to insert a reference can
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
962 already be specified in `reftex-cite-format'.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
963 The function will be called with two arguments, the CITATION KEY and the
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
964 DEFAULT FORMAT, which is taken from `reftex-cite-format'. The function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
965 should return the string to insert into the buffer."
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
966 :group 'reftex-citation-support
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
967 :type 'function)
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
968
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
969 (defcustom reftex-select-bib-mode-hook nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
970 "Mode hook for reftex-select-bib-mode."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
971 :group 'reftex-citation-support
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
972 :type 'hook)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
973
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
974
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
975 ;; Viewing Cross References and Citations
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
976 (defgroup reftex-viewing-cross-references-and-citations nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
977 "Displaying cross references and citations."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
978 :group 'reftex)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
979
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
980 (defcustom reftex-auto-view-crossref t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
981 "*Non-nil means, initially turn automatic viewing of crossref info on.
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
982 Automatic viewing of crossref info normally uses the echo area.
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
983 Whenever point is on the argument of a \\ref or \\cite macro, and no
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
984 other message is being displayed, the echo area will display
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
985 information about that cross reference. You can also set the variable
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
986 to the symbol `window'. In this case a small temporary window is
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
987 used for the display.
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
988 This feature can be turned on and of from the menu
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
989 (Ref->Options->Crossref Viewing)."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
990 :group 'reftex-viewing-cross-references-and-citations
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
991 :type '(choice (const :tag "off" nil)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
992 (const :tag "in Echo Area" t)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
993 (const :tag "in Other Window" window)))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
994
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
995 (defcustom reftex-idle-time 1.2
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
996 "*Time (secs) Emacs has to be idle before automatic crossref display is done."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
997 :group 'reftex-viewing-cross-references-and-citations
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
998 :type 'number)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
999
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1000 (defcustom reftex-revisit-to-echo nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1001 "*Non-nil means, automatic citation display will revisit files if necessary.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1002 When nil, citation display in echo area will only be active for cached
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1003 entries and for BibTeX database files with live associated buffers."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1004 :group 'reftex-viewing-cross-references-and-citations
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1005 :type 'boolean)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1006
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1007 (defcustom reftex-cache-cite-echo t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1008 "*Non-nil means, the information displayed in the echo area for cite macros
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1009 is cached and even saved along with the parsing information. The cache
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1010 survives document scans. In order to clear it, use M-x reftex-reset-mode."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1011 :group 'reftex-viewing-cross-references-and-citations
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1012 :type 'boolean)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1013
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1014 (defcustom reftex-display-copied-context-hook nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1015 "Normal Hook which is run before context is displayed anywhere. Designed
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1016 for X-Symbol, but may have other uses as well."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1017 :group 'reftex-viewing-cross-references-and-citations
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1018 :group 'reftex-referencing-labels
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1019 :type 'hook)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1020
23344
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1021 ;; Finding Files --------------------------------------------------------
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1022
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1023 (defgroup reftex-finding-files nil
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1024 "Finding files on search paths."
23344
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1025 :group 'reftex)
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1026
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1027 (defcustom reftex-texpath-environment-variables '("TEXINPUTS")
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1028 "*List of specifications how to retrieve the search path for TeX files.
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1029 Several entries are possible.
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1030 - If an element is the name of an environment variable, its content is used.
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1031 - If an element starts with an exclamation mark, it is used as a command
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1032 to retrieve the path. A typical command with the kpathsearch library would
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1033 be `!kpsewhich -show-path=.tex'.
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1034 - Otherwise the element itself is interpreted as a path.
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1035 Multiple directories can be separated by the system dependent `path-separator'.
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1036 Directories ending in `//' or `!!' will be expanded recursively.
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1037 See also `reftex-use-external-file-finders'."
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1038 :group 'reftex-finding-files
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1039 :set 'reftex-set-dirty
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1040 :type '(repeat (string :tag "Specification")))
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1041
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1042 (defcustom reftex-bibpath-environment-variables '("BIBINPUTS" "TEXBIB")
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1043 "*List of specifications how to retrieve search path for .bib database files.
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1044 Several entries are possible.
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1045 - If an element is the name of an environment variable, its content is used.
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1046 - If an element starts with an exclamation mark, it is used as a command
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1047 to retrieve the path. A typical command with the kpathsearch library would
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1048 be `!kpsewhich -show-path=.bib'.
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1049 - Otherwise the element itself is interpreted as a path.
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1050 Multiple directories can be separated by the system dependent `path-separator'.
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1051 Directories ending in `//' or `!!' will be expanded recursively.
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1052 See also `reftex-use-external-file-finders'."
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1053 :group 'reftex-citation-support
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1054 :group 'reftex-finding-files
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1055 :set 'reftex-set-dirty
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1056 :type '(repeat (string :tag "Specification")))
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1057
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1058 (defcustom reftex-file-extensions '(("tex" . (".tex" ".ltx"))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1059 ("bib" . (".bib")))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1060 "*Association list with file extensions for different file types.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1061 This is a list of items, each item is like: (TYPE . (DEF-EXT OTHER-EXT ...))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1062
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1063 TYPE: File type like \"bib\" or \"tex\".
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1064 DEF-EXT: The default extension for that file type, like \".tex\" or \".bib\".
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1065 OTHER-EXT: Any number of other legal extensions for this file type.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1066
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1067 When a files is searched and it does not have any of the legal extensions,
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1068 we try the default extension first, and then the naked file name."
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1069 :group 'reftex-finding-files
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1070 :type '(repeat (cons (string :tag "File type")
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1071 (repeat (string :tag "Extension")))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1072
23344
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1073 (defcustom reftex-search-unrecursed-path-first t
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1074 "*Non-nil means, search all specified directories before trying recursion.
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1075 Thus, in a path \".//:/tex/\", search first \"./\", then \"/tex/\" and then
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1076 all subdirectories of \"./\". If this option is nil, the subdirectories of
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1077 \"./\" are searched before \"/tex/\". This is mainly for speed - most of the
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1078 time the recursive path is for the system files and not for the user files.
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1079 Set this to nil if the default makes RefTeX finding files with equal names
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1080 in wrong sequence."
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1081 :group 'reftex-finding-files
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1082 :type 'boolean)
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1083
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1084 (defcustom reftex-use-external-file-finders nil
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1085 "*Non-nil means, use external programs to find files.
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1086 Normally, RefTeX searches the paths given in the environment variables
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1087 TEXINPUTS and BIBINPUTS to find TeX files and BibTeX database files.
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1088 With this option turned on, it calls an external program specified in the
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1089 option `reftex-external-file-finders' instead. As a side effect,
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1090 the variables `reftex-texpath-environment-variables' and
23344
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1091 `reftex-bibpath-environment-variables' will be ignored."
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1092 :group 'reftex-finding-files
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1093 :type 'boolean)
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1094
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1095 (defcustom reftex-external-file-finders '(("tex" . "kpsewhich -format=.tex %f")
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1096 ("bib" . "kpsewhich -format=.bib %f"))
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1097 "*Association list with external programs to call for finding files.
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1098 Each entry is a cons cell (TYPE . PROGRAM).
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1099 TYPE is either \"tex\" or \"bib\". PROGRAM is the external program to use with
23344
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1100 any arguments. %f will be replaced by the name of the file to be found.
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1101 Note that these commands will be executed directly, not via a shell.
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1102 Only relevant when `reftex-use-external-file-finders' is non-nil."
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1103 :group 'reftex-finding-files
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1104 :type '(repeat (cons (string :tag "File type")
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1105 (string :tag "Program "))))
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1106
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1107 ;; Tuning the parser ----------------------------------------------------
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1108
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1109 (defgroup reftex-optimizations-for-large-documents nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1110 "Configuration of parser speed and memory usage."
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1111 :group 'reftex)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1112
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1113 (defcustom reftex-keep-temporary-buffers 1
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1114 "*Non-nil means, keep buffers created for parsing and lookup.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1115 RefTeX sometimes needs to visit files related to the current document.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1116 We distinguish files visited for
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1117 PARSING: Parts of a multifile document loaded when (re)-parsing the document.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1118 LOOKUP: BibTeX database files and TeX files loaded to find a reference,
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1119 to display label context, etc.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1120 The created buffers can be kept for later use, or be thrown away immediately
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1121 after use, depending on the value of this variable:
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1122
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1123 nil Throw away as much as possible.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1124 t Keep everything.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1125 1 Throw away buffers created for parsing, but keep the ones created
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1126 for lookup.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1127
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1128 If a buffer is to be kept, the file is visited normally (which is potentially
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1129 slow but will happen only once).
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1130 If a buffer is to be thrown away, the initialization of the buffer depends
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1131 upon the variable `reftex-initialize-temporary-buffers'."
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1132 :group 'reftex-optimizations-for-large-documents
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1133 :type '(choice
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1134 (const :tag "Throw away everything" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1135 (const :tag "Keep everything" t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1136 (const :tag "Keep lookup buffers only" 1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1137
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1138 (defcustom reftex-initialize-temporary-buffers nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1139 "*Non-nil means do initializations even when visiting file temporarily.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1140 When nil, RefTeX may turn off find-file hooks and other stuff to briefly
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1141 visit a file.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1142 When t, the full default initializations are done (find-file-hook etc.).
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1143 Instead of t or nil, this variable may also be a list of hook functions to
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1144 do a minimal initialization."
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1145 :group 'reftex-optimizations-for-large-documents
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1146 :type '(choice
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1147 (const :tag "Read files literally" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1148 (const :tag "Fully initialize buffers" t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1149 (repeat :tag "Hook functions" :value (nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1150 (function-item))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1151
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1152 (defcustom reftex-no-include-regexps '("\\.pstex_t\\'")
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1153 "*List of regular expressions to exclude certain input files from parsing.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1154 If the name of a file included via \\include or \\input is matched by any
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1155 of the regular expressions in this list, that file is not parsed by RefTeX."
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1156 :group 'reftex-optimizations-for-large-documents
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1157 :type '(repeat (regexp)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1158
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1159 (defcustom reftex-enable-partial-scans nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1160 "*Non-nil means, re-parse only 1 file when asked to re-parse.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1161 Re-parsing is normally requested with a `C-u' prefix to many RefTeX commands,
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1162 or with the `r' key in menus. When this option is t in a multifile document,
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1163 we will only parse the current buffer, or the file associated with the label
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1164 or section heading near point in a menu. Requesting re-parsing of an entire
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1165 multifile document then requires a `C-u C-u' prefix or the capital `R' key
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1166 in menus."
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1167 :group 'reftex-optimizations-for-large-documents
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1168 :type 'boolean)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1169
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1170 (defcustom reftex-allow-automatic-rescan t
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1171 "*Non-nil means, RefTeX may rescan the document when this seems necessary.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1172 Currently this applies only to rescanning after label insertion, when
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1173 the new label cannot be inserted correctly into the internal label
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1174 list."
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1175 :group 'reftex-optimizations-for-large-documents
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1176 :type 'boolean)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1177
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1178 (defcustom reftex-save-parse-info nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1179 "*Non-nil means, save information gathered with parsing in a file.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1180 The file MASTER.rel in the same directory as MASTER.tex is used to save the
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1181 information. When this variable is t,
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1182 - accessing the parsing information for the first time in an editing session
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1183 will read that file (if available) instead of parsing the document.
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1184 - exiting Emacs or killing a buffer in reftex-mode will cause a new version
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1185 of the file to be written."
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1186 :group 'reftex-optimizations-for-large-documents
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1187 :type 'boolean)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1188
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1189 (defcustom reftex-use-multiple-selection-buffers nil
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1190 "*Non-nil means use a separate selection buffer for each label type.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1191 These buffers are kept from one selection to the next and need not to be
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1192 created for each use - so the menu generally comes up faster. The
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1193 selection buffers will be erased (and therefore updated) automatically
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1194 when new labels in its category are added. See the variable
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1195 `reftex-auto-update-selection-buffers'."
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1196 :group 'reftex-optimizations-for-large-documents
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1197 :group 'reftex-referencing-labels
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1198 :type 'boolean)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1199
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1200 (defcustom reftex-auto-update-selection-buffers t
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1201 "*Non-nil means, selection buffers will be updated automatically.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1202 When a new label is defined with `reftex-label', all selection buffers
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1203 associated with that label category are emptied, in order to force an
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1204 update upon next use. When nil, the buffers are left alone and have to be
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1205 updated by hand, with the `g' key from the label selection process.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1206 The value of this variable will only have any effect when
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1207 `reftex-use-multiple-selection-buffers' is non-nil."
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1208 :group 'reftex-optimizations-for-large-documents
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1209 :group 'reftex-referencing-labels
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1210 :type 'boolean)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1211
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1212 ;; Fontification and Faces ----------------------------------------------
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1213
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1214 (defgroup reftex-fontification-configurations nil
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1215 "Options concerning the faces used in RefTeX."
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1216 :group 'reftex)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1217
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1218 (defcustom reftex-use-fonts t
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1219 "*Non-nil means, use fonts in *toc* and selection buffers.
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1220 Font-lock must be loaded as well to actually get fontified display.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1221 When changing this option, a rescan may be necessary to activate the change."
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1222 :group 'reftex-fontification-configurations
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1223 :type 'boolean)
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1224
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1225 (defcustom reftex-refontify-context 1
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1226 "*Non-nil means, re-fontify the context in the label menu with font-lock.
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1227 This slightly slows down the creation of the label menu. It is only necessary
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1228 when you definitely want the context fontified.
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1229
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1230 This option may have 3 different values:
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1231 nil Never refontify.
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1232 t Always refontify.
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1233 1 Refontify when absolutely necessary, e.g. when old versions of X-Symbol.
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1234 The option is ignored when `reftex-use-fonts' is nil."
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1235 :group 'reftex-fontification-configurations
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1236 :group 'reftex-referencing-labels
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1237 :type '(choice
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1238 (const :tag "Never" nil)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1239 (const :tag "Always" t)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1240 (const :tag "When necessary" 1)))
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1241
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1242 (defcustom reftex-highlight-selection 'cursor
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1243 "*Non-nil mean, highlight selected text in selection and *toc* buffers.
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1244 Normally, the text near the cursor is the selected text, and it is
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1245 highlighted. This is the entry most keys in the selction and *toc*
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1246 buffers act on. However, if you mainly use the mouse to select an
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1247 item, you may find it nice to have mouse-triggered highlighting
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1248 instead or as well. The variable may have one of these values:
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1249
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1250 nil No highlighting.
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1251 cursor Highlighting is cursor driven.
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1252 mouse Highlighting is mouse driven.
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1253 both Both cursor and mouse trigger highlighting.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1254
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1255 Changing this variable requires to rebuild the selection and *toc* buffers
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1256 to become effective (keys `g' or `r')."
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1257 :group 'reftex-fontification-configurations
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1258 :type '(choice
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1259 (const :tag "Never" nil)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1260 (const :tag "Cursor driven" cursor)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1261 (const :tag "Mouse driven" mouse)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1262 (const :tag "Mouse and Cursor driven." both)))
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1263
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1264 (defcustom reftex-cursor-selected-face 'highlight
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1265 "Face name to highlight cursor selected item in toc and selection buffers.
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1266 See also the variable `reftex-highlight-selection'."
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1267 :group 'reftex-fontification-configurations
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1268 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1269 (defcustom reftex-mouse-selected-face 'secondary-selection
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1270 "Face name to highlight mouse selected item in toc and selection buffers.
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1271 See also the variable `reftex-highlight-selection'."
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1272 :group 'reftex-fontification-configurations
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1273 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1274 (defcustom reftex-file-boundary-face 'font-lock-comment-face
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1275 "Face name for file boundaries in selection buffer."
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1276 :group 'reftex-fontification-configurations
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1277 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1278 (defcustom reftex-label-face 'font-lock-constant-face
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1279 "Face name for labels in selection buffer."
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1280 :group 'reftex-fontification-configurations
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1281 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1282 (defcustom reftex-section-heading-face 'font-lock-function-name-face
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1283 "Face name for section headings in toc and selection buffers."
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1284 :group 'reftex-fontification-configurations
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1285 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1286 (defcustom reftex-toc-header-face 'font-lock-comment-face
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1287 "Face name for the header of a toc buffer."
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1288 :group 'reftex-fontification-configurations
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1289 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1290 (defcustom reftex-bib-author-face 'font-lock-keyword-face
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1291 "Face name for author names in bib selection buffer."
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1292 :group 'reftex-fontification-configurations
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1293 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1294 (defcustom reftex-bib-year-face 'font-lock-comment-face
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1295 "Face name for year in bib selection buffer."
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1296 :group 'reftex-fontification-configurations
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1297 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1298 (defcustom reftex-bib-title-face 'font-lock-function-name-face
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1299 "Face name for article title in bib selection buffer."
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1300 :group 'reftex-fontification-configurations
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1301 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1302 (defcustom reftex-bib-extra-face 'font-lock-comment-face
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1303 "Face name for bibliographic information in bib selection buffer."
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1304 :group 'reftex-fontification-configurations
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1305 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1306
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1307 (defcustom reftex-pre-refontification-functions nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1308 "X-Symbol specific hook.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1309 Functions get two arguments, the buffer from where the command started and a
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1310 symbol indicating in what context the hook is called."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1311 :group 'reftex-fontification-configurations
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1312 :type 'hook)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1313
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1314 ;; Miscellaneous configurations -----------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1315
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1316 (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
1317 "Collection of further configurations."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1318 :group 'reftex)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1319
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1320 (defcustom reftex-extra-bindings nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1321 "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
1322 These extra bindings are located in the users `C-c letter' map."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1323 :group 'reftex-miscellaneous-configurations
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1324 :type 'boolean)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1325
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1326 (defcustom reftex-plug-into-AUCTeX nil
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1327 "*Plug-in flags for AUCTeX interface.
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1328 This variable is a list of 4 boolean flags. When a flag is non-nil,
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1329 RefTeX will
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1330
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1331 - supply labels in new sections and environments (flag 1)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1332 - supply arguments for macros like `\\label'. (flag 2)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1333 - supply arguments for macros like `\\ref'. (flag 3)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1334 - supply arguments for macros like `\\cite'. (flag 4)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1335
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1336 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
1337 plug-ins on or off, respectively.
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1338 \\<LaTeX-mode-map>Supplying labels in new sections and environments applies when creating
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1339 sections with \\[LaTeX-section] and environments with \\[LaTeX-environment].
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1340 Supplying macro arguments applies when you insert such a macro interactively
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1341 with \\[TeX-insert-macro].
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1342 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
1343 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
1344 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
1345 :group 'reftex-miscellaneous-configurations
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1346 :group 'LaTeX
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1347 :type '(choice
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1348 (const :tag "No plug-ins" nil)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1349 (const :tag "All possible plug-ins" t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1350 (list
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1351 :tag "Individual choice"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1352 :value (t t t t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1353 (boolean :tag "supply label in new sections and environments")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1354 (boolean :tag "supply argument for macros like `\\label' ")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1355 (boolean :tag "supply argument for macros like `\\ref' ")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1356 (boolean :tag "supply argument for macros like `\\cite' ")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1357 )))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1358
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1359 (defcustom reftex-allow-detached-macro-args nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1360 "*Non-nil means, allow arguments of macros to be detached by whitespace.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1361 When this is t, `aaa' will be considered as argument of \\bb in the following
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1362 construct: \\bbb [xxx] {aaa}."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1363 :group 'texmathp
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1364 :type 'boolean)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1365
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1366
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1367 (defcustom reftex-load-hook nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1368 "Hook which is being run when loading reftex.el."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1369 :group 'reftex-miscellaneous-configurations
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1370 :type 'hook)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1371
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1372 (defcustom reftex-mode-hook nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1373 "Hook which is being run when turning on RefTeX mode."
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1374 :group 'reftex-miscellaneous-configurations
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1375 :type 'hook)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1376
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1377 ;;; =========================================================================
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1378 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1379 ;;; Define the formal stuff for a minor mode named RefTeX.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1380 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1381
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1382 (defconst reftex-version "RefTeX version 3.42"
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
1383 "Version string for RefTeX.")
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
1384
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1385 (defvar reftex-mode nil
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1386 "Determines if RefTeX mode is active.")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1387 (make-variable-buffer-local 'reftex-mode)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1388
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1389 (defvar reftex-mode-map (make-sparse-keymap)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1390 "Keymap for RefTeX mode.")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1391
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1392 (defvar reftex-mode-menu nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1393
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1394 ;;;###autoload
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1395 (defun turn-on-reftex ()
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1396 "Turn on RefTeX mode."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1397 (reftex-mode t))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1398
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1399 ;;;###autoload
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1400 (defun reftex-mode (&optional arg)
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
1401 "Minor mode with distinct support for \\label, \\ref and \\cite in LaTeX.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1402
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1403 Labels can be created with `\\[reftex-label]' and referenced with `\\[reftex-reference]'.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1404 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
1405 context of the label definition. The selected label is inserted as a
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
1406 \\ref macro.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1407
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1408 Citations can be made with `\\[reftex-citation]' which will use a regular expression
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1409 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
1410 database. The selected citation is inserted as a \\cite macro.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1411
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1412 A Table of Contents of the entire (multifile) document with browsing
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1413 capabilities is available with `\\[reftex-toc]'.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1414
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1415 Most command have help available on the fly. This help is accessed by
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1416 pressing `?' to any prompt mentioning this feature.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1417
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1418 Extensive documentation about RefTeX is available in Info format.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1419 You can view this information with `\\[reftex-info]'.
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1420
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1421 \\{reftex-mode-map}
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1422 Under X, these and other functions will also be available as `Ref' menu
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1423 on the menu bar.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1424
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1425 ------------------------------------------------------------------------------"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1426
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1427 (interactive "P")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1428 (setq reftex-mode (not (or (and (null arg) reftex-mode)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1429 (<= (prefix-numeric-value arg) 0))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1430
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1431 (if reftex-mode
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1432 (progn
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1433 ;; Mode was turned on
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1434 (easy-menu-add reftex-mode-menu)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1435 (and reftex-plug-into-AUCTeX
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1436 (reftex-plug-into-AUCTeX))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1437 (unless (get 'reftex-auto-view-crossref 'initialized)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1438 (and reftex-auto-view-crossref
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1439 (reftex-toggle-auto-view-crossref))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1440 (put 'reftex-auto-view-crossref 'initialized t))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1441 (run-hooks 'reftex-mode-hook))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1442 ;; Mode was turned off
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1443 (easy-menu-remove reftex-mode-menu)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1444
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1445 (if (fboundp 'add-minor-mode)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1446 ;; Use it so that we get the extras
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1447 (progn
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1448 (put 'reftex-mode ':included '(memq major-mode '(latex-mode tex-mode)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1449 (put 'reftex-mode ':menu-tag "RefTeX Mode")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1450 (add-minor-mode 'reftex-mode " Ref" reftex-mode-map))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1451 ;; The standard way
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1452 (unless (assoc 'reftex-mode minor-mode-alist)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1453 (push '(reftex-mode " Ref") minor-mode-alist))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1454 (unless (assoc 'reftex-mode minor-mode-map-alist)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1455 (push (cons 'reftex-mode reftex-mode-map) minor-mode-map-alist)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1456
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1457 ;;; =========================================================================
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1458 ;;;
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1459 ;;; 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
1460 (defvar TeX-master)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1461 (defvar LaTeX-section-hook)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1462 (defvar LaTeX-label-function)
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1463 (defvar tex-main-file)
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1464 (defvar outline-minor-mode)
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
1465 (defvar font-lock-mode)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1466 (defvar font-lock-fontify-region-function)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1467 (defvar font-lock-syntactic-keywords)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1468
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1469 ;;; =========================================================================
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1470 ;;;
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1471 ;;; Multibuffer Variables
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1472 ;;;
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1473 ;;; Technical notes: These work as follows: We keep just one list
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1474 ;;; 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
1475 ;;; `reftex-master-index-list' is an alist which connects the true file name
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1476 ;;; 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
1477 ;;; document. Each buffer has local variables which point to these symbols.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1478
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1479 ;; List of variables which handle the multifile stuff.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1480 ;; This list is used to tie, untie, and reset these symbols.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1481 (defconst reftex-multifile-symbols
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1482 '(reftex-docstruct-symbol))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1483
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1484 ;; Alist connecting master file names with the corresponding lisp symbols.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1485 (defvar reftex-master-index-list nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1486
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1487 ;; Last index used for a master file.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1488 (defvar reftex-multifile-index 0)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1489
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1490 ;; Variable holding the symbol with the label list of the document.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1491 (defvar reftex-docstruct-symbol nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1492 (make-variable-buffer-local 'reftex-docstruct-symbol)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1493
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1494 (defun reftex-next-multifile-index ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1495 ;; Return the next free index for multifile symbols.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1496 (incf reftex-multifile-index))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1497
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1498 (defun reftex-tie-multifile-symbols ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1499 ;; Tie the buffer-local symbols to globals connected with the master file.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1500 ;; If the symbols for the current master file do not exist, they are created.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1501
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1502 (let* ((master (file-truename (reftex-TeX-master-file)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1503 (index (assoc master reftex-master-index-list))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1504 (symlist reftex-multifile-symbols)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1505 symbol symname newflag)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1506 ;; Find the correct index.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1507 (if index
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1508 ;; symbols do exist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1509 (setq index (cdr index))
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1510 ;; Get a new index and add info to the alist.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1511 (setq index (reftex-next-multifile-index)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1512 newflag t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1513 (push (cons master index) reftex-master-index-list))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1514
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1515 ;; Get/create symbols and tie them.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1516 (while symlist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1517 (setq symbol (car symlist)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1518 symlist (cdr symlist)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1519 symname (symbol-name symbol))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1520 (set symbol (intern (concat symname "-" (int-to-string index))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1521 (put (symbol-value symbol) ':master-index index)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1522 ;; Initialize if new symbols.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1523 (if newflag (set (symbol-value symbol) nil)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1524
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1525 ;; Return t if the symbols did already exist, nil when we've made them.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1526 (not newflag)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1527
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1528 (defun reftex-untie-multifile-symbols ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1529 ;; Remove ties from multifile symbols, so that next use makes new ones.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1530 (let ((symlist reftex-multifile-symbols)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1531 (symbol nil))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1532 (while symlist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1533 (setq symbol (car symlist)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1534 symlist (cdr symlist))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1535 (set symbol nil))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1536
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1537 (defun reftex-TeX-master-file ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1538 ;; Return the name of the master file associated with the current buffer.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1539 ;; 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
1540 ;; 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
1541 ;; variable tex-main-file.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1542 (let
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1543 ((master
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1544 (cond
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1545 ((fboundp 'TeX-master-file) ; AUCTeX is loaded. Use its mechanism.
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1546 (condition-case nil
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1547 (TeX-master-file t)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1548 (error (buffer-file-name))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1549 ((boundp 'TeX-master) ; The variable is defined - lets use it.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1550 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1551 ((eq TeX-master t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1552 (buffer-file-name))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1553 ((eq TeX-master 'shared)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1554 (setq TeX-master (read-file-name "Master file: "
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1555 nil nil t nil)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1556 (TeX-master)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1557 (t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1558 (setq TeX-master (read-file-name "Master file: "
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1559 nil nil t nil)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1560 ((boundp 'tex-main-file)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1561 ;; This is the variable from the default TeX modes.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1562 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1563 ((stringp tex-main-file)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1564 ;; ok, this must be it
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1565 tex-main-file)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1566 (t
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1567 ;; In this case, the buffer is its own master.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1568 (buffer-file-name))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1569 (t
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1570 ;; Know nothing about master file. Assume this is a master file.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1571 (buffer-file-name)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1572 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1573 ((null master)
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
1574 (error "Need a filename for this buffer, please save it first"))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
1575 ((or (file-exists-p (concat master ".tex"))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
1576 (reftex-get-buffer-visiting (concat master ".tex")))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
1577 ;; Ahh, an extra .tex was missing...
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
1578 (setq master (concat master ".tex")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1579 ((or (file-exists-p master)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1580 (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
1581 ;; We either see the file, or have a buffer on it. OK.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1582 )
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1583 (t
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1584 ;; Use buffer file name.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1585 (buffer-file-name)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1586 (expand-file-name master)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1587
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1588 ;;; =========================================================================
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1589 ;;;
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1590 ;;; Functions to parse the buffer and to create and reference labels.
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1591
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1592 ;; 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
1593
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1594 ;; Prompt used for label type queries directed to the user.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1595 (defconst reftex-type-query-prompt nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1596
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1597 ;; Help string for label type queries.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1598 (defconst reftex-type-query-help nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1599
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1600 ;; Alist relating label type to reference format.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1601 (defconst reftex-typekey-to-format-alist nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1602
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1603 ;; Alist relating label type to label affix.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1604 (defconst reftex-typekey-to-prefix-alist nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1605
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1606 ;; Alist relating environments or macros to label type and context regexp.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1607 (defconst reftex-env-or-mac-alist nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1608
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1609 ;; List of macros carrying a label.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1610 (defconst reftex-label-mac-list nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1611
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1612 ;; List of environments carrying a label.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1613 (defconst reftex-label-env-list nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1614
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1615 ;; List of all typekey letters in use.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1616 (defconst reftex-typekey-list nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1617
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1618 ;; Alist relating magic words to a label type.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1619 (defconst reftex-words-to-typekey-alist nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1620
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1621 ;; The last list-of-labels entry used in a reference.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1622 (defvar reftex-last-used-reference (list nil nil nil nil))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1623
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1624 ;; The message when follow-mode is suspended
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1625 (defconst reftex-no-follow-message
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1626 "No follow-mode into unvisited file. Press SPC to visit it.")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1627 (defconst reftex-no-info-message
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1628 "%s: info not available, use `\\[reftex-view-crossref]' to get it.")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1629
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1630 ;; Global variables used for communication between functions.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1631 (defvar reftex-default-context-position nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1632 (defvar reftex-location-start nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1633 (defvar reftex-call-back-to-this-buffer nil)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
1634 (defvar reftex-select-return-marker (make-marker))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1635 (defvar reftex-active-toc nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1636 (defvar reftex-tex-path nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1637 (defvar reftex-bib-path nil)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
1638 (defvar reftex-last-follow-point nil)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1639 (defvar reftex-latex-syntax-table nil)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1640 (defvar reftex-prefix nil)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1641 (defvar reftex-section-levels-all nil)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1642 (defvar reftex-buffers-with-changed-invisibility nil)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1643 (defvar reftex-callback-fwd t)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1644
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1645 ;; List of buffers created temporarily for lookup, which should be killed.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1646 (defvar reftex-buffers-to-kill nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1647
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1648 ;; Regexp to find anything.
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
1649 (defvar reftex-section-regexp nil)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1650 (defvar reftex-section-or-include-regexp nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1651 (defvar reftex-everything-regexp nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1652 (defvar reftex-find-label-regexp-format nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1653 (defvar reftex-find-label-regexp-format2 nil)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1654
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1655 ;;; The parser functions -----------------------------------------------------
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1656
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1657 (defvar reftex-memory nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1658 "Memorizes old variable values to indicate changes in these variables.")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1659
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1660 (defun reftex-access-scan-info (&optional rescan file)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1661 "Ensure access to the scanning info for the current file."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1662 ;; When the multifile symbols are not yet tied,
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1663 ;; tie them. When they are empty or RESCAN is non-nil, scan the document.
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1664 ;; But, when RESCAN is -1, don't rescan even if docstruct is empty.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1665 ;; When FILE is non-nil, parse only from that file.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1666
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1667 ;; Make sure we have the symbols tied
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1668 (if (eq reftex-docstruct-symbol nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1669 ;; Symbols are not yet tied: Tie them.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1670 (reftex-tie-multifile-symbols))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1671
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1672 (reftex-ensure-compiled-variables)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1673
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1674 (when (or (null (symbol-value reftex-docstruct-symbol))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1675 (member rescan '(t 1 (4) (16))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1676 ;; The docstruct will change: Remove selection buffers.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1677 (save-excursion
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1678 (reftex-erase-buffer "*toc*")
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1679 (reftex-erase-all-selection-buffers)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1680
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1681 (if (and (null (symbol-value reftex-docstruct-symbol))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1682 (not (member rescan '(t 1 (4) (16))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1683 reftex-save-parse-info)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1684 ;; Try to read the stuff from a file
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1685 (reftex-access-parse-file 'read))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1686
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1687 (cond
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1688 ((equal rescan -1)) ;; We are not allowed to scan.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1689 ((not (symbol-value reftex-docstruct-symbol))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1690 ;; Scan the whole document
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1691 (reftex-do-parse 1 file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1692 ((member rescan '(t 1 (4) (16)))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1693 ;; Scan whatever was required by the caller.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1694 (reftex-do-parse rescan file))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1695
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1696 (defun reftex-parse-one ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1697 "Re-parse this file."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1698 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1699 (let ((reftex-enable-partial-scans t))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1700 (reftex-access-scan-info '(4))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1701
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1702 (defun reftex-parse-all ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1703 "Re-parse entire document."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1704 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1705 (reftex-access-scan-info '(16)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1706
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1707 (defun reftex-do-parse (rescan &optional file)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1708 "Do a document rescan. When allowed, do only a partial scan from FILE."
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1709
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1710 ;; Normalize the rescan argument
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1711 (setq rescan (cond ((eq rescan t) t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1712 ((eq rescan 1) 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1713 ((equal rescan '(4)) t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1714 ((equal rescan '(16)) 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1715 (t 1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1716
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1717 ;; Partial scans only when allowed
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1718 (unless reftex-enable-partial-scans
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1719 (setq rescan 1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1720
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1721 ;; Do the scanning.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1722
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1723 (let* ((old-list (symbol-value reftex-docstruct-symbol))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1724 (master (reftex-TeX-master-file))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1725 (true-master (file-truename master))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1726 (master-dir (file-name-as-directory (file-name-directory master)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1727 (file (or file (buffer-file-name)))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1728 (true-file (file-truename file))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1729 (bibview-cache (assq 'bibview-cache old-list))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1730 from-file appendix docstruct tmp)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1731
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1732 ;; Make sure replacement is really an option here
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1733 (when (and (eq rescan t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1734 (not (and (member (list 'bof file) old-list)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1735 (member (list 'eof file) old-list))))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1736 ;; Scan whole document because no such file section exists
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1737 (setq rescan 1))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1738 (when (string= true-file true-master)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1739 ;; Scan whole document because this file is the master
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1740 (setq rescan 1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1741
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1742 ;; From which file do we start?
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1743 (setq from-file
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1744 (cond ((eq rescan t) (or file master))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1745 ((eq rescan 1) master)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1746 (t (error "This should not happen (reftex-do-parse)"))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1747
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1748 ;; Find active toc entry and initialize section-numbers
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1749 (setq reftex-active-toc (reftex-last-assoc-before-elt
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1750 'toc (list 'bof from-file) old-list)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1751 appendix (reftex-last-assoc-before-elt
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1752 'appendix (list 'bof from-file) old-list))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1753
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1754 (reftex-init-section-numbers reftex-active-toc appendix)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1755
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1756 (if (eq rescan 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1757 (message "Scanning entire document...")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1758 (message "Scanning document from %s..." from-file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1759
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1760 (save-window-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1761 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1762 (unwind-protect
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1763 (setq docstruct
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1764 (reftex-parse-from-file
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1765 from-file docstruct master-dir))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1766 (reftex-kill-temporary-buffers))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1767
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1768 (message "Scanning document... done")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1769
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1770 ;; Turn the list around.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1771 (setq docstruct (nreverse docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1772
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1773 ;; Set or insert
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1774 (setq docstruct (reftex-replace-label-list-segment
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1775 old-list docstruct (eq rescan 1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1776
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1777 ;; Add all missing information
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1778 (unless (assq 'label-numbers docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1779 (push (cons 'label-numbers nil) docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1780 (unless (assq 'master-dir docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1781 (push (cons 'master-dir master-dir) docstruct))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1782 (unless (assq 'bibview-cache docstruct)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1783 (push (cons 'bibview-cache (cdr bibview-cache)) docstruct))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1784 (let* ((bof1 (memq (assq 'bof docstruct) docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1785 (bof2 (assq 'bof (cdr bof1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1786 (is-multi (not (not (and bof1 bof2))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1787 (entry (or (assq 'is-multi docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1788 (car (push (list 'is-multi is-multi) docstruct)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1789 (setcdr entry (cons is-multi nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1790 (unless (assq 'xr docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1791 (let* ((allxr (reftex-all-assq 'xr-doc docstruct))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1792 (alist (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1793 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1794 (lambda (x)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1795 (if (setq tmp (reftex-locate-file (nth 2 x) "tex"
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1796 master-dir))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1797 (cons (nth 1 x) tmp)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1798 (message "Can't find external document %s"
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1799 (nth 2 x))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1800 nil)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1801 allxr))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1802 (alist (delq nil alist))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1803 (allprefix (delq nil (mapcar 'car alist)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1804 (regexp (if allprefix
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1805 (concat "\\`\\("
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1806 (mapconcat 'identity allprefix "\\|")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1807 "\\)")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1808 "\\\\\\\\\\\\"))) ; this will never match
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1809 (push (list 'xr alist regexp) docstruct)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1810
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1811 (set reftex-docstruct-symbol docstruct)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1812 (put reftex-docstruct-symbol 'modified t)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1813
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1814 (defun reftex-parse-from-file (file docstruct master-dir)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1815 ;; Scan the buffer for labels and save them in a list.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1816 (let ((regexp reftex-everything-regexp)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1817 (bound 0)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1818 file-found tmp include-file
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1819 (level 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1820 (highest-level 100)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1821 toc-entry next-buf buf)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1822
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1823 (catch 'exit
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1824 (setq file-found (reftex-locate-file file "tex" master-dir))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1825 (if (and (not file-found)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1826 (setq buf (reftex-get-buffer-visiting file)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1827 (setq file-found (buffer-file-name buf)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1828
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1829 (unless file-found
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1830 (push (list 'file-error file) docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1831 (throw 'exit nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1832
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1833 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1834
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1835 (message "Scanning file %s" file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1836 (set-buffer
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1837 (setq next-buf
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1838 (reftex-get-file-buffer-force
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1839 file-found
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1840 (not (eq t reftex-keep-temporary-buffers)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1841
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1842 ;; Begin of file mark
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1843 (setq file (buffer-file-name))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1844 (push (list 'bof file) docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1845
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1846 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1847 (save-restriction
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1848 (widen)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1849 (goto-char 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1850
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1851 (while (re-search-forward regexp nil t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1852
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1853 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1854
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1855 ((match-end 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1856 ;; It is a label
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1857 (push (reftex-label-info (reftex-match-string 1) file bound)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1858 docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1859
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1860 ((match-end 3)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1861 ;; It is a section
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1862 (setq bound (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1863
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1864 ;; Insert in List
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1865 (setq toc-entry (reftex-section-info file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1866 (setq level (nth 5 toc-entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1867 (setq highest-level (min highest-level level))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1868 (if (= level highest-level)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1869 (message
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1870 "Scanning %s %s ..."
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1871 (car (rassoc level reftex-section-levels))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1872 (nth 6 toc-entry)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1873
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1874 (push toc-entry docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1875 (setq reftex-active-toc toc-entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1876
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1877 ((match-end 7)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1878 ;; It's an include or input
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1879 (setq include-file (reftex-match-string 7))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1880 ;; Test if this file should be ignored
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1881 (unless (delq nil (mapcar
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1882 (lambda (x) (string-match x include-file))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1883 reftex-no-include-regexps))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1884 ;; Parse it
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1885 (setq docstruct
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1886 (reftex-parse-from-file
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1887 include-file
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1888 docstruct master-dir))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1889
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1890 ((match-end 9)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1891 ;; Appendix starts here
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1892 (reftex-init-section-numbers nil t)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1893 (push (cons 'appendix t) docstruct))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1894
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1895 ((match-end 10)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1896 ;; A macro with label
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1897 (save-excursion
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1898 (let* ((mac (reftex-match-string 10))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1899 (label (progn (goto-char (match-end 10))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1900 (save-match-data
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1901 (reftex-no-props
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1902 (reftex-nth-arg-wrapper
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1903 mac)))))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1904 (typekey (nth 1 (assoc mac reftex-env-or-mac-alist)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1905 (entry (progn (if typekey
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1906 ;; A typing macro
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1907 (goto-char (match-end 0))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1908 ;; A newtral macro
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1909 (goto-char (match-end 10))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1910 (reftex-move-over-touching-args))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1911 (reftex-label-info
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1912 label file bound nil nil))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1913 (push entry docstruct))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1914 (t (error "This should not happen (reftex-parse-from-file)")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1915 )
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1916
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1917 ;; Find bibliography statement
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1918 (when (setq tmp (reftex-locate-bibliography-files master-dir))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1919 (push (cons 'bib tmp) docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1920
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1921 (goto-char 1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1922 (when (re-search-forward
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1923 "\\(\\`\\|[\n\r]\\)[ \t]*\\\\begin{thebibliography}" nil t)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1924 (push (cons 'thebib file) docstruct))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1925
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1926 ;; Find external document specifications
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1927 (goto-char 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1928 (while (re-search-forward "[\n\r][ \t]*\\\\externaldocument\\(\\[\\([^]]*\\)\\]\\)?{\\([^}]+\\)}" nil t)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1929 (push (list 'xr-doc (reftex-match-string 2)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1930 (reftex-match-string 3))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1931 docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1932
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1933 ;; End of file mark
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1934 (push (list 'eof file) docstruct))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1935
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1936 ;; Kill the scanned buffer
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1937 (reftex-kill-temporary-buffers next-buf))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1938
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1939 ;; Return the list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1940 docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1941
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1942 (defun reftex-locate-bibliography-files (master-dir)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1943 ;; Scan buffer for bibliography macro and return file list.
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1944 (let (files)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1945 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1946 (goto-char (point-min))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1947 (when (re-search-forward
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1948 "\\(\\`\\|[\n\r]\\)[ \t]*\\\\bibliography{[ \t]*\\([^}]+\\)" nil t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1949 (setq files (split-string (reftex-match-string 2)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1950 "[ \t\n\r]*,[ \t\n\r]*"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1951 (setq files
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1952 (mapcar
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1953 (lambda (x)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1954 (if (or (member x reftex-bibfile-ignore-list)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1955 (delq nil (mapcar (lambda (re) (string-match re x))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1956 reftex-bibfile-ignore-regexps)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1957 ;; excluded file
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1958 nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1959 ;; find the file
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1960 (reftex-locate-file x "bib" master-dir)))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1961 files))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1962 (delq nil files)))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1963
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1964 (defun reftex-replace-label-list-segment (old insert &optional entirely)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1965 ;; Replace the segment in OLD which corresponds to INSERT.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1966 ;; Works with side effects, directly changes old.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1967 ;; If entirely is t, just return INSERT.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1968 ;; This function also makes sure the old toc markers do not point anywhere.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1969
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1970 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1971 (entirely
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1972 (reftex-silence-toc-markers old (length old))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1973 insert)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1974 (t (let* ((new old)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1975 (file (nth 1 (car insert)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1976 (eof-list (member (list 'eof file) old))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1977 (bof-list (member (list 'bof file) old))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1978 n)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1979 (if (not (and bof-list eof-list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1980 (error "Cannot splice")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1981 ;; Splice
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1982 (reftex-silence-toc-markers bof-list (- (length bof-list)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1983 (length eof-list)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1984 (setq n (- (length old) (length bof-list)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1985 (setcdr (nthcdr n new) (cdr insert))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1986 (setcdr (nthcdr (1- (length new)) new) (cdr eof-list)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1987 new))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1988
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1989 (defun reftex-silence-toc-markers (list n)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1990 ;; Set all toc markers in the first N entries in list to nil
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1991 (while (and list (> (decf n) -1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1992 (and (eq (car (car list)) 'toc)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1993 (markerp (nth 4 (car list)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1994 (set-marker (nth 4 (car list)) nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1995 (pop list)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1996
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1997 (defun reftex-access-parse-file (action)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1998 "Perform ACTION on the parse file (the .rel file).
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1999 Valid actions are: readable, restore, read, kill, write."
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2000 (let* ((list (symbol-value reftex-docstruct-symbol))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2001 (docstruct-symbol reftex-docstruct-symbol)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2002 (master (reftex-TeX-master-file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2003 (enable-local-variables nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2004 (file (if (string-match "\\.[a-zA-Z]+\\'" master)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2005 (concat (substring master 0 (match-beginning 0)) ".rel")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2006 (concat master ".rel"))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2007 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2008 ((eq action 'readable)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2009 (file-readable-p file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2010 ((eq action 'restore)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2011 (put reftex-docstruct-symbol 'modified nil)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2012 (if (eq reftex-docstruct-symbol nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2013 ;; Symbols are not yet tied: Tie them.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2014 (reftex-tie-multifile-symbols))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2015 (if (file-exists-p file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2016 ;; load the file and return t for success
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2017 (condition-case nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2018 (progn (load-file file) t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2019 (error (set reftex-docstruct-symbol nil)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2020 (error "Error while loading file %s" file)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2021 ;; Throw an exception if the file does not exist
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2022 (error "No restore file %s" file)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2023 ((eq action 'read)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2024 (put reftex-docstruct-symbol 'modified nil)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2025 (if (file-exists-p file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2026 ;; load the file and return t for success
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2027 (condition-case nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2028 (progn (load-file file) t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2029 (error (message "Error while loading file %s" file)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2030 (set reftex-docstruct-symbol nil)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2031 nil))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2032 ;; return nil for failure, but no exception
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2033 nil))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2034 ((eq action 'kill)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2035 ;; Remove the file
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2036 (when (and (file-exists-p file) (file-writable-p file))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2037 (message "Unlinking file %s" file)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2038 (delete-file file)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2039 (t
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2040 (put docstruct-symbol 'modified nil)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2041 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2042 (if (file-writable-p file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2043 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2044 (message "Writing parse file %s" (abbreviate-file-name file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2045 (find-file file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2046 (erase-buffer)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2047 (insert (format ";; RefTeX parse info file\n"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2048 (insert (format ";; File: %s\n" master))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2049 (insert (format ";; User: %s (%s)\n\n"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2050 (user-login-name) (user-full-name)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2051 (insert "(set reftex-docstruct-symbol '(\n\n")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2052 (let ((standard-output (current-buffer)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2053 (mapcar
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2054 (function
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2055 (lambda (x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2056 (cond ((eq (car x) 'toc)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2057 ;; A toc entry. Do not save the marker.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2058 ;; Save the markers position at position 8
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2059 (print (list 'toc "toc" (nth 2 x) (nth 3 x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2060 nil (nth 5 x) (nth 6 x) (nth 7 x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2061 (or (and (markerp (nth 4 x))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2062 (marker-position (nth 4 x)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2063 (nth 8 x)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2064 (t (print x)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2065 list))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2066 (insert "))\n\n")
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2067 (save-buffer 0)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2068 (kill-buffer (current-buffer)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2069 (error "Cannot write to file %s" file)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2070 t))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2071
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2072 (defun reftex-kill-buffer-hook ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2073 "Save RefTeX's parse file for this buffer if the information has changed."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2074 ;; Save the parsing information if it was modified.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2075 ;; This function should be installed in `kill-buffer-hook'.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2076 ;; We are careful to make sure nothing goes wring in this function.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2077 (when (and (boundp 'reftex-mode) reftex-mode
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2078 (boundp 'reftex-save-parse-info) reftex-save-parse-info
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2079 (boundp 'reftex-docstruct-symbol) reftex-docstruct-symbol
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2080 (symbol-value reftex-docstruct-symbol)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2081 (get reftex-docstruct-symbol 'modified))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2082 ;; Write the file.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2083 (condition-case nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2084 (reftex-access-parse-file 'write)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2085 (error nil))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2086
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2087 (defun reftex-kill-emacs-hook ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2088 "Call `reftex-kill-buffer-hook' on all buffers."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2089 ;; This function should be installed in `kill-emacs-hook'.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2090 (save-excursion
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2091 (mapcar (lambda (buf)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2092 (set-buffer buf)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2093 (reftex-kill-buffer-hook))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2094 (buffer-list))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2095
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2096 (defun reftex-section-info (file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2097 ;; Return a section entry for the current match.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2098 ;; Carefull: This function expects the match-data to be still in place!
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2099 (let* ((marker (set-marker (make-marker) (1- (match-beginning 3))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2100 (macro (reftex-match-string 3))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2101 (star (= ?* (char-after (match-end 3))))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2102 (level (cdr (assoc macro reftex-section-levels-all)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2103 (section-number (reftex-section-number level star))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2104 (text1 (save-match-data (save-excursion (reftex-context-substring))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2105 (literal (buffer-substring-no-properties
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2106 (1- (match-beginning 3))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2107 (min (point-max) (+ (match-end 0) (length text1) 1))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2108 ;; Literal can be too short since text1 too short. No big problem.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2109 (text (reftex-nicify-text text1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2110
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2111 ;; Add section number and indentation
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2112 (setq text
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2113 (concat
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2114 (make-string (* reftex-level-indent level) ?\ )
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2115 (if (nth 1 reftex-label-menu-flags) ; section number flag
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2116 (concat section-number " "))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2117 text))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2118 (list 'toc "toc" text file marker level section-number
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2119 literal (marker-position marker))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2120
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2121 (defun reftex-label-info-update (cell)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2122 ;; Update information about just one label in a different file.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2123 ;; CELL contains the old info list
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2124 (let* ((label (nth 0 cell))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2125 (typekey (nth 1 cell))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2126 ;; (text (nth 2 cell))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2127 (file (nth 3 cell))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2128 (comment (nth 4 cell))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2129 (note (nth 5 cell))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2130 (buf (reftex-get-file-buffer-force
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2131 file (not (eq t reftex-keep-temporary-buffers)))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2132 (if (not buf)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2133 (list label typekey "" file comment "LOST LABEL. RESCAN TO FIX.")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2134 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2135 (set-buffer buf)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2136 (save-restriction
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2137 (widen)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2138 (goto-char 1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2139
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2140 (if (or (re-search-forward
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2141 (format reftex-find-label-regexp-format
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2142 (regexp-quote label)) nil t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2143 (re-search-forward
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2144 (format reftex-find-label-regexp-format2
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2145 (regexp-quote label)) nil t))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2146
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2147 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2148 (backward-char 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2149 (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
2150 (list label typekey "" file "LOST LABEL. RESCAN TO FIX.")))))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2151
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2152 (defun reftex-label-info (label &optional file bound derive env-or-mac)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2153 ;; Return info list on LABEL at point.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2154 (let* ((env-or-mac (or env-or-mac (reftex-label-location bound)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2155 (typekey (nth 1 (assoc env-or-mac reftex-env-or-mac-alist)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2156 (file (or file (buffer-file-name)))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2157 (parse (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
2158 (text (reftex-short-context env-or-mac parse reftex-location-start
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2159 derive))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2160 (in-comment (reftex-in-comment)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2161 (list label typekey text file in-comment)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2162
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2163 (defun reftex-in-comment ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2164 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2165 (skip-chars-backward "^%\n\r")
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2166 (eq (preceding-char) ?%)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2167
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2168 (defun reftex-short-context (env parse &optional bound derive)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2169 ;; Get about one line of useful context for the label definition at point.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2170
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2171 (if (consp parse)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2172 (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
2173
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2174 (reftex-nicify-text
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2175
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2176 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2177
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2178 ((null parse)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2179 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2180 (reftex-context-substring)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2181
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2182 ((eq parse t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2183 (if (string= env "section")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2184 ;; special treatment for section labels
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2185 (save-excursion
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2186 (if (and (re-search-backward reftex-section-or-include-regexp
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2187 (point-min) t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2188 (match-end 2))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2189 (progn
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2190 (goto-char (match-end 0))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2191 (reftex-context-substring))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2192 (if reftex-active-toc
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2193 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2194 (string-match "{\\([^}]*\\)" (nth 7 reftex-active-toc))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2195 (match-string 1 (nth 7 reftex-active-toc)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2196 "SECTION HEADING NOT FOUND")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2197 (save-excursion
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2198 (goto-char reftex-default-context-position)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2199 (unless (eq (string-to-char env) ?\\)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2200 (reftex-move-over-touching-args))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2201 (reftex-context-substring))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2202
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2203 ((stringp parse)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2204 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2205 (if (re-search-backward parse bound t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2206 (progn
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2207 (goto-char (match-end 0))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2208 (reftex-context-substring))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2209 "NO MATCH FOR CONTEXT REGEXP")))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2210
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2211 ((integerp parse)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2212 (or (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2213 (goto-char reftex-default-context-position)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2214 (reftex-nth-arg
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2215 parse
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2216 (nth 6 (assoc env reftex-env-or-mac-alist))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2217 ""))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2218
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2219 ((fboundp parse)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
2220 ;; A hook function. Call it.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2221 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2222 (condition-case error-var
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2223 (funcall parse env)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2224 (error (format "HOOK ERROR: %s" (cdr error-var))))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2225 (t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2226 "ILLEGAL VALUE OF PARSE"))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2227
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2228 (defun reftex-nicify-text (text)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2229 ;; Make TEXT nice for inclusion as context into label menu.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2230 ;; 1. remove line breaks and extra white space
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2231 (while (string-match "[\n\r\t]\\|[ \t][ \t]+" text)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2232 (setq text (replace-match " " nil t text)))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2233 ;; 2. cut before the next `\end{' or `\item' or `\\'
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2234 (if (string-match "\\(\\\\end{\\|\\\\item\\|\\\\\\\\\\).*" text)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2235 (setq text (replace-match "" nil t text)))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2236 ;; 3. kill the embedded label
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2237 (if (string-match "\\\\label{[^}]*}" text)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2238 (setq text (replace-match "" nil t text)))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2239 ;; 4. remove leading garbage
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2240 (if (string-match "\\`[ }]+" text)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2241 (setq text (replace-match "" nil t text)))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2242 ;; 5. limit length
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2243 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2244 ((> (length text) 100) (substring text 0 100))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2245 ((= (length text) 0) (make-string 1 ?\ ))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2246 (t text)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2247
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2248 (defun reftex-where-am-I ()
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2249 ;; Return the docstruct entry above point. Actually returns a cons
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2250 ;; cell in which the cdr is a flag indicating if the information is
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2251 ;; exact (t) or approximate (nil).
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2252
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2253 (let ((docstruct (symbol-value reftex-docstruct-symbol))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2254 (cnt 0) rtn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2255 found)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2256 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2257 (while (not rtn)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2258 (incf cnt)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2259 (setq found (re-search-backward reftex-everything-regexp nil t))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2260 (setq rtn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2261 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2262 ((not found)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2263 ;; no match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2264 (or
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2265 (car (member (list 'bof (buffer-file-name)) docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2266 (not (setq cnt 2))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2267 (assq 'bof docstruct) ;; for safety reasons
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2268 'corrupted))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2269 ((match-end 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2270 ;; Label
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2271 (assoc (reftex-match-string 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2272 (symbol-value reftex-docstruct-symbol)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2273 ((match-end 3)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2274 ;; Section
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2275 (goto-char (1- (match-beginning 3)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2276 (let* ((list (member (list 'bof (buffer-file-name))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2277 docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2278 (endelt (car (member (list 'eof (buffer-file-name))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2279 list)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2280 rtn1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2281 (while (and list (not (eq endelt (car list))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2282 (if (and (eq (car (car list)) 'toc)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2283 (string= (buffer-file-name)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2284 (nth 3 (car list))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2285 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2286 ((equal (point)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2287 (or (and (markerp (nth 4 (car list)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2288 (marker-position (nth 4 (car list))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2289 (nth 8 (car list))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2290 ;; Fits with marker position or recorded position
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2291 (setq rtn1 (car list) list nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2292 ((looking-at (reftex-make-regexp-allow-for-ctrl-m
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2293 (nth 7 (car list))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2294 ;; Same title
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2295 (setq rtn1 (car list) list nil cnt 2))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2296 (pop list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2297 rtn1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2298 ((match-end 7)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2299 ;; Input or include...
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2300 (car
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2301 (member (list 'eof (reftex-locate-file
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2302 (reftex-match-string 7) "tex"
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2303 (cdr (assq 'master-dir docstruct))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2304 docstruct)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2305 ((match-end 9)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2306 (assq 'appendix (symbol-value reftex-docstruct-symbol)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2307 ((match-end 10)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2308 (save-excursion
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2309 (goto-char (match-end 10))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2310 (assoc (reftex-no-props
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2311 (reftex-nth-arg-wrapper
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2312 (reftex-match-string 10)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2313 (symbol-value reftex-docstruct-symbol))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2314 (t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2315 (error "This should not happen (reftex-where-am-I)"))))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2316 (cons rtn (eq cnt 1))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2317
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2318 (defun reftex-label-location (&optional bound)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2319 "Return the environment or macro which determines the label type at point.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2320 If optional BOUND is an integer, limit backward searches to that point."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2321
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2322 (let* ((loc1 (reftex-what-macro reftex-label-mac-list bound))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2323 (loc2 (reftex-what-environment reftex-label-env-list bound))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2324 (p1 (or (cdr loc1) 0))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2325 (p2 (or (cdr loc2) 0)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2326
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2327 (setq reftex-location-start (max p1 p2))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2328 (if (>= p1 p2)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2329 (progn
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2330 (setq reftex-default-context-position (+ p1 (length (car loc1))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2331 (or (car loc1) "section"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2332 (setq reftex-default-context-position (+ p2 8 (length (car loc2))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2333 (or (car loc2) "section"))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2334
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2335 (defun reftex-parse-args (macro)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2336 ;; Return a list of macro name, nargs, arg-nr which is label and a list of
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2337 ;; optional argument indices.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2338 (if (string-match "[[{]\\*?[]}]" macro)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2339 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2340 (let ((must-match (substring macro 0 (match-beginning 0)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2341 (args (substring macro (match-beginning 0)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2342 opt-list nlabel (cnt 0))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2343 (while (string-match "\\`[[{]\\(\\*\\)?[]}]" args)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2344 (incf cnt)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2345 (when (eq ?\[ (string-to-char args))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2346 (push cnt opt-list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2347 (when (and (match-end 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2348 (not nlabel))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2349 (setq nlabel cnt))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2350 (setq args (substring args (match-end 0))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2351 (list must-match cnt nlabel opt-list)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2352 nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2353
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2354 (defsubst reftex-move-to-next-arg (&optional ignore)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2355 ;; Assuming that we are at the end of a macro name or a macro argument,
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2356 ;; move forward to the opening parenthesis of the next argument.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2357 ;; This function understands the splitting of macros over several lines
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2358 ;; in TeX.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2359 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2360 ;; Just to be quick:
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2361 ((memq (following-char) '(?\[ ?\{)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2362 ;; Do a search
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2363 ((and reftex-allow-detached-macro-args
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2364 (looking-at "[ \t]*[\n\r]?\\([ \t]*%[^\n\r]*[\n\r]\\)*[ \t]*[[{]"))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2365 (goto-char (1- (match-end 0)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2366 t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2367 (t nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2368
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2369 (defsubst reftex-move-to-previous-arg (&optional bound)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2370 ;; Assuming that we are in front of a macro argument,
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2371 ;; move backward to the closing parenthesis of the previous argument.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2372 ;; This function understands the splitting of macros over several lines
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2373 ;; in TeX.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2374 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2375 ;; Just to be quick:
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2376 ((memq (preceding-char) '(?\] ?\})))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2377 ;; Do a search
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2378 ((and reftex-allow-detached-macro-args
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2379 (re-search-backward
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2380 "[]}][ \t]*[\n\r]?\\([ \t]*%[^\n\r]*[\n\r]\\)*[ \t]*\\=" bound t))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2381 (goto-char (1+ (match-beginning 0)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2382 t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2383 (t nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2384
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2385 (defun reftex-nth-arg-wrapper (key)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2386 (let ((entry (assoc key reftex-env-or-mac-alist)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2387 (reftex-nth-arg (nth 5 entry) (nth 6 entry))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2388
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2389 (defun reftex-nth-arg (n &optional opt-args)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2390 ;; Return the nth following {} or [] parentheses content.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2391 ;; OPT-ARGS is a list of argument numbers which are optional.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2392
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2393 ;; If we are sitting at a macro start, skip to end of macro name.
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2394 (and (eq (following-char) ?\\) (skip-chars-forward "a-zA-Z*\\\\"))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2395
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2396 (if (= n 1000)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2397 ;; Special case: Skip all touching arguments
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2398 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2399 (reftex-move-over-touching-args)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2400 (reftex-context-substring))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2401
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2402 ;; Do the real thing.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2403 (let ((cnt 1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2404
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2405 (when (reftex-move-to-next-arg)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2406
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2407 (while (< cnt n)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2408 (while (and (member cnt opt-args)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2409 (eq (following-char) ?\{))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2410 (incf cnt))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2411 (when (< cnt n)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2412 (unless (and (condition-case nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2413 (or (forward-list 1) t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2414 (error nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2415 (reftex-move-to-next-arg)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2416 (incf cnt))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2417 (setq cnt 1000))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2418
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2419 (while (and (memq cnt opt-args)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2420 (eq (following-char) ?\{))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2421 (incf cnt)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2422 (if (and (= n cnt)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2423 (> (skip-chars-forward "{\\[") 0))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2424 (reftex-context-substring)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2425 nil))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2426
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2427 (defun reftex-move-over-touching-args ()
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2428 (condition-case nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2429 (while (memq (following-char) '(?\[ ?\{))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2430 (forward-list 1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2431 (error nil)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2432
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2433 (defun reftex-context-substring ()
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2434 ;; Return up to 150 chars from point
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2435 ;; When point is just after a { or [, limit string to matching parenthesis
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2436 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2437 ((or (= (preceding-char) ?\{)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2438 (= (preceding-char) ?\[))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2439 ;; Inside a list - get only the list.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2440 (buffer-substring-no-properties
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2441 (point)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2442 (min (+ (point) 150)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2443 (point-max)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2444 (condition-case nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2445 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2446 (up-list 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2447 (1- (point)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2448 (error (point-max))))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2449 (t
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2450 ;; no list - just grab 150 characters
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2451 (buffer-substring-no-properties (point)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2452 (min (+ (point) 150) (point-max))))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2453
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2454 ;; Variable holding the vector with section numbers
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2455 (defvar reftex-section-numbers [0 0 0 0 0 0 0 0])
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2456
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2457 (defun reftex-init-section-numbers (&optional toc-entry appendix)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2458 ;; 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
2459 ;; in the toc entry.
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2460 (let* ((level (or (nth 5 toc-entry) -1))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2461 (numbers (nreverse (split-string (or (nth 6 toc-entry) "") "\\.")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2462 (depth (1- (length reftex-section-numbers)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2463 (i depth) number-string)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2464 (while (>= i 0)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2465 (if (> i level)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2466 (aset reftex-section-numbers i 0)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2467 (setq number-string (or (car numbers) "0"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2468 (if (string-match "\\`[A-Z]\\'" number-string)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2469 (aset reftex-section-numbers i
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2470 (- (string-to-char number-string) ?A -1))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2471 (aset reftex-section-numbers i (string-to-int number-string)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2472 (pop numbers))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2473 (decf i)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2474 (put 'reftex-section-numbers 'appendix appendix))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2475
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2476 (defun reftex-section-number (&optional level star)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2477 ;; Return a string with the current section number.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2478 ;; When LEVEL is non-nil, increase section numbers on that level.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2479 (let* ((depth (1- (length reftex-section-numbers))) idx n (string "")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2480 (appendix (get 'reftex-section-numbers 'appendix)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2481 (when level
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2482 (when (and (> level -1) (not star))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2483 (aset reftex-section-numbers
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2484 level (1+ (aref reftex-section-numbers level))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2485 (setq idx (1+ level))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2486 (when (not star)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2487 (while (<= idx depth)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2488 (aset reftex-section-numbers idx 0)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2489 (incf idx))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2490 (setq idx 0)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2491 (while (<= idx depth)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2492 (setq n (aref reftex-section-numbers idx))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2493 (setq string (concat string (if (not (string= string "")) "." "")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2494 (int-to-string n)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2495 (incf idx))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2496 (save-match-data
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2497 (if (string-match "\\`\\([@0]\\.\\)+" string)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2498 (setq string (replace-match "" nil nil string)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2499 (if (string-match "\\(\\.0\\)+\\'" string)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2500 (setq string (replace-match "" nil nil string)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2501 (if (and appendix
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2502 (string-match "\\`[0-9]+" string))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2503 (setq string
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2504 (concat
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2505 (char-to-string
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2506 (1- (+ ?A (string-to-int (match-string 0 string)))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2507 (substring string (match-end 0))))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2508 (if star
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2509 (concat (make-string (1- (length string)) ?\ ) "*")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2510 string)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2511
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2512 (defun reftex-is-multi ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2513 ;; Tell if this is a multifile document. When not sure, say yes.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2514 (let ((entry (assq 'is-multi (symbol-value reftex-docstruct-symbol))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2515 (if entry
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2516 (nth 1 entry)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2517 t)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2518
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2519 (defun reftex-typekey-check (typekey conf-variable &optional n)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2520 ;; Check if CONF-VARIABLE is true or contains TYPEKEY
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2521 (and n (setq conf-variable (nth n conf-variable)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2522 (or (eq conf-variable t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2523 (and (stringp conf-variable)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2524 (string-match (concat "[" conf-variable "]") typekey))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2525
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2526 (defun reftex-all-document-files (&optional relative)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2527 "Return a list of all files belonging to the current document.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2528 When RELATIVE is non-nil, give file names relative to directory
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2529 of master file."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2530 (let* ((all (symbol-value reftex-docstruct-symbol))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2531 (master-dir (file-name-directory (reftex-TeX-master-file)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2532 (re (concat "\\`" (regexp-quote master-dir)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2533 file-list tmp file)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2534 (while (setq tmp (assoc 'bof all))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2535 (setq file (nth 1 tmp)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2536 all (cdr (memq tmp all)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2537 (and relative
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2538 (string-match re file)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2539 (setq file (substring file (match-end 0))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2540 (push file file-list))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2541 (nreverse file-list)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2542
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2543 ;;; Creating labels ---------------------------------------------------------
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2544
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2545 (defun reftex-label (&optional environment no-insert)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2546 "Insert a unique label. Return the label.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2547 If ENVIRONMENT is given, don't bother to find out yourself.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2548 If NO-INSERT is non-nil, do not insert label into buffer.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2549 With prefix arg, force to rescan document first.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2550 When you are prompted to enter or confirm a label, and you reply with
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2551 just the prefix or an empty string, no label at all will be inserted.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2552 A new label is also recorded into the label list.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2553 This function is controlled by the settings of reftex-insert-label-flags."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2554
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2555 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2556
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2557 ;; Ensure access to scanning info and rescan buffer if prefix are is '(4).
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2558 (reftex-access-scan-info current-prefix-arg)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2559
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2560 ;; Find out what kind of environment this is and abort if necessary.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2561 (if (or (not environment)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2562 (not (assoc environment reftex-env-or-mac-alist)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2563 (setq environment (reftex-label-location)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2564 (unless environment
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2565 (error "Can't figure out what kind of label should be inserted"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2566
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2567 ;; Ok, go ahead.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2568 (catch 'exit
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2569 (let* ((entry (assoc environment reftex-env-or-mac-alist))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2570 (typekey (nth 1 entry))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2571 (format (nth 3 entry))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2572 (macro-cell (reftex-what-macro 1))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2573 (entry1 (assoc (car macro-cell) reftex-env-or-mac-alist))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2574 label naked prefix valid default force-prompt rescan-is-useful)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2575 (when (and (or (nth 5 entry) (nth 5 entry1))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2576 (memq (preceding-char) '(?\[ ?\{)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2577 ;; This is an argument of a label macro. Insert naked label.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2578 (setq naked t format "%s"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2579
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2580 (setq prefix (or (cdr (assoc typekey reftex-typekey-to-prefix-alist))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2581 (concat typekey "-")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2582 ;; Replace any escapes in the prefix
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2583 (setq prefix (reftex-replace-prefix-escapes prefix))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2584
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2585 ;; Make a default label.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2586 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2587
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2588 ((reftex-typekey-check typekey (nth 0 reftex-insert-label-flags))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2589 ;; Derive a label from context.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2590 (setq reftex-active-toc (reftex-last-assoc-before-elt
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2591 'toc (car (reftex-where-am-I))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2592 (symbol-value reftex-docstruct-symbol)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2593 (setq default (reftex-no-props
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2594 (nth 2 (reftex-label-info " " nil nil t))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2595 ;; Catch the cases where the is actually no context available.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2596 (if (or (string-match "NO MATCH FOR CONTEXT REGEXP" default)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2597 (string-match "ILLEGAL VALUE OF PARSE" default)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2598 (string-match "SECTION HEADING NOT FOUND" default)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2599 (string-match "HOOK ERROR" default)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2600 (string-match "^[ \t]*$" default))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2601 (setq default prefix
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2602 force-prompt t) ; need to prompt
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2603 (setq default
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2604 (concat prefix
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2605 (funcall reftex-string-to-label-function default)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2606
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2607 ;; Make it unique.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2608 (setq default (reftex-uniquify-label default nil "-"))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2609
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2610 ((reftex-typekey-check typekey (nth 1 reftex-insert-label-flags))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2611 ;; Minimal default: the user will be prompted.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2612 (setq default prefix))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2613
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2614 (t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2615 ;; Make an automatic label.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2616 (setq default (reftex-uniquify-label prefix t))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2617
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2618 ;; Should we ask the user?
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2619 (if (or (reftex-typekey-check typekey
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2620 (nth 1 reftex-insert-label-flags)) ; prompt
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2621 force-prompt)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2622
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2623 (while (not valid)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2624 ;; iterate until we get a legal label
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2625
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2626 (setq label (read-string
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2627 (if naked "Naked Label: " "Label: ")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2628 default))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2629
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2630 ;; Lets make sure that this is a legal label
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2631 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2632
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2633 ((string-match (concat "\\`\\(" (regexp-quote prefix)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2634 "\\)?[ \t]*\\'")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2635 label)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2636 ;; No label at all, please
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2637 (message "No label inserted.")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2638 (throw 'exit nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2639
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2640 ;; Test if label contains strange characters
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2641 ((string-match reftex-label-illegal-re label)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2642 (message "Label \"%s\" contains illegal characters" label)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2643 (ding)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2644 (sit-for 2))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2645
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2646 ;; Look it up in the label list
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2647 ((setq entry (assoc label
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2648 (symbol-value reftex-docstruct-symbol)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2649 (ding)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2650 (if (y-or-n-p
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2651 (format "Label '%s' exists. Use anyway? " label))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2652 (setq valid t)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2653
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2654 ;; Label is ok
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2655 (t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2656 (setq valid t))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2657 (setq label default))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2658
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2659 ;; Insert the label into the label list
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2660 (let* ((here-I-am-info
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2661 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2662 (if (and (or naked no-insert)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2663 (integerp (cdr macro-cell)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2664 (goto-char (cdr macro-cell)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2665 (reftex-where-am-I)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2666 (here-I-am (car here-I-am-info))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2667 (note (if (cdr here-I-am-info)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2668 ""
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2669 "POSITION UNCERTAIN. RESCAN TO FIX."))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2670 (file (buffer-file-name))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2671 (text nil)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2672 (tail (memq here-I-am (symbol-value reftex-docstruct-symbol))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2673
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2674 (or (cdr here-I-am-info) (setq rescan-is-useful t))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2675
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2676 (when tail
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2677 (push (list label typekey text file nil note) (cdr tail))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2678 (put reftex-docstruct-symbol 'modified t)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2679
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2680 ;; Insert the label into the buffer
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2681 (unless no-insert
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2682 (insert
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2683 (if reftex-format-label-function
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2684 (funcall reftex-format-label-function label format)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2685 (format format label)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2686 (if (and reftex-plug-into-AUCTeX
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2687 (fboundp 'LaTeX-add-labels))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2688 ;; Tell AUCTeX about this
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2689 (LaTeX-add-labels label)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2690
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2691 ;; Delete the corresponding selection buffers to force update on next use.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2692 (when reftex-auto-update-selection-buffers
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2693 (reftex-erase-buffer (reftex-make-selection-buffer-name typekey))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2694 (reftex-erase-buffer (reftex-make-selection-buffer-name " ")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2695
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2696 (when (and rescan-is-useful reftex-allow-automatic-rescan)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2697 (reftex-parse-one))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2698
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2699 ;; return value of the function is the label
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2700 label)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2701
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2702 (defun reftex-string-to-label (string)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2703 "Convert a string (a sentence) to a label.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2704 Uses `reftex-derive-label-parameters' and `reftex-label-illegal-re'. It
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2705 also applies `reftex-translate-to-ascii-function' to the string."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2706 (when (and reftex-translate-to-ascii-function
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2707 (fboundp reftex-translate-to-ascii-function))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2708 (setq string (funcall reftex-translate-to-ascii-function string)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2709 (apply 'reftex-convert-string string
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2710 "[-~ \t\n\r,;]+" reftex-label-illegal-re nil nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2711 reftex-derive-label-parameters))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2712
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2713 (defun reftex-abbreviate-title (string)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2714 (reftex-convert-string string "[-~ \t\n\r,;]" nil t t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2715 5 40 nil 1 " " (nth 5 reftex-derive-label-parameters)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2716
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2717 (defun reftex-convert-string (string split-re illegal-re dot keep-fp
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2718 nwords maxchar illegal abbrev sep
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2719 ignore-words &optional downcase)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2720 "Convert a string (a sentence) to something shorter.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2721 SPLIT-RE is the regular expression used to split the string into words.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2722 ILLEGAL-RE matches characters which are illegal in the final string.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2723 DOT t means add dots to abbreviated words.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2724 KEEP-FP t means to keep a final punctuation when applicable.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2725 NWORDS Number of words to use.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2726 MAXCHAR Maximum number of characters in the final string.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2727 ILLEGAL nil: Throw away any words containing stuff matched with ILLEGAL-RE.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2728 t: Throw away only the matched part, not the whole word.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2729 ABBREV nil: Never abbreviate words.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2730 t: Always abbreviate words (see `reftex-abbrev-parameters').
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2731 not t and not nil: Abbreviate words if necessary to shorten
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2732 string below MAXCHAR.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2733 SEP String separating different words in the output string.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2734 IGNORE-WORDS List of words which should be removed from the string."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2735
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2736 (let* ((words0 (split-string string (or split-re "[ \t\n\r]")))
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
2737 (reftex-label-illegal-re (or illegal-re "\000"))
23344
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
2738 (abbrev-re (concat
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
2739 "\\`\\("
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
2740 (make-string (nth 0 reftex-abbrev-parameters) ?.)
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
2741 "[" (nth 2 reftex-abbrev-parameters) "]*"
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
2742 "\\)"
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
2743 "[" (nth 3 reftex-abbrev-parameters) "]"
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
2744 (make-string (1- (nth 1 reftex-abbrev-parameters)) ?.)))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2745 words word)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2746
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2747 ;; Remove words from the ignore list or with funny characters
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2748 (while (setq word (pop words0))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2749 (if downcase (setq word (downcase word)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2750 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2751 ((member (downcase word) ignore-words))
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
2752 ((string-match reftex-label-illegal-re word)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2753 (when illegal
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
2754 (while (string-match reftex-label-illegal-re word)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2755 (setq word (replace-match "" nil nil word)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2756 (push word words)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2757 (t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2758 (push word words))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2759 (setq words (nreverse words))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2760
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2761 ;; Restrict number of words
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2762 (if (> (length words) nwords)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2763 (setcdr (nthcdr (1- nwords) words) nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2764
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2765 ;; First, try to use all words
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2766 (setq string (mapconcat 'identity words sep))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2767
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2768 ;; Abbreviate words if enforced by user settings or string length
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2769 (if (or (eq t abbrev)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2770 (and abbrev
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2771 (> (length string) maxchar)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2772 (setq words
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2773 (mapcar
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2774 (function
23344
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
2775 (lambda (w) (if (string-match abbrev-re w)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2776 (if dot
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2777 (concat (match-string 1 w) ".")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2778 (match-string 1 w))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2779 w)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2780 words)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2781 string (mapconcat 'identity words sep)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2782
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2783 ;; Shorten if still to long
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2784 (setq string
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2785 (if (> (length string) maxchar)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2786 (substring string 0 maxchar)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2787 string))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2788
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2789 ;; Delete the final punctuation, if any
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2790 (if (and (not keep-fp) (string-match "\\s.+\\'" string))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2791 (setq string (replace-match "" nil nil string)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2792 string))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2793
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
2794 (defun reftex-latin1-to-ascii (string)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2795 ;; Translate the upper 128 chars in the Latin-1 charset to ASCII equivalents
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2796 (let ((tab "@@@@@@@@@@@@@@@@@@'@@@@@@@@@@@@@ icLxY|S\"ca<--R-o|23'uq..1o>423?AAAAAAACEEEEIIIIDNOOOOOXOUUUUYP3aaaaaaaceeeeiiiidnooooo:ouuuuypy")
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2797 (emacsp (not (featurep 'xemacs))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2798 (mapconcat
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2799 (lambda (c)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2800 (cond ((and (> c 127) (< c 256)) ; 8 bit Latin-1
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2801 (char-to-string (aref tab (- c 128))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2802 ((and emacsp ; Not for XEmacs
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2803 (> c 2175) (< c 2304)) ; Mule Latin-1
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2804 (char-to-string (aref tab (- c 2176))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2805 (t (char-to-string c))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2806 string "")))
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
2807
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2808 (defun reftex-replace-prefix-escapes (prefix)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2809 ;; Replace %escapes in a label prefix
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2810 (save-match-data
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2811 (let (letter (num 0) replace)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2812 (while (string-match "\\%\\([a-zA-Z]\\)" prefix num)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2813 (setq letter (match-string 1 prefix))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2814 (setq replace
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2815 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2816 ((equal letter "f")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2817 (file-name-sans-extension
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2818 (file-name-nondirectory (buffer-file-name))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2819 ((equal letter "F")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2820 (let ((masterdir (file-name-directory (reftex-TeX-master-file)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2821 (file (file-name-sans-extension (buffer-file-name))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2822 (if (string-match (concat "\\`" (regexp-quote masterdir))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2823 file)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2824 (substring file (length masterdir))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2825 file)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2826 ((equal letter "u")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2827 (or (user-login-name) ""))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2828 (t "")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2829 (setq num (1- (+ (match-beginning 1) (length replace)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2830 prefix (replace-match replace nil nil prefix)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2831 prefix)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2832
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2833 (defun reftex-uniquify-label (label &optional force separator)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2834 ;; Make label unique by appending a number.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2835 ;; Optional FORCE means, force appending a number, even if label is unique.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2836 ;; Optional SEPARATOR is a string to stick between label and number.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2837
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2838 ;; Ensure access to scanning info
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2839 (reftex-access-scan-info)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2840
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2841 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2842 ((and (not force)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2843 (not (assoc label (symbol-value reftex-docstruct-symbol))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2844 label)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2845 (t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2846 (let* ((label-numbers (assq 'label-numbers
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2847 (symbol-value reftex-docstruct-symbol)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2848 (label-numbers-alist (cdr label-numbers))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2849 (cell (or (assoc label label-numbers-alist)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2850 (car (setcdr label-numbers
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2851 (cons (cons label 0)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2852 label-numbers-alist)))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2853 (num (1+ (cdr cell)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2854 (sep (or separator "")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2855 (while (assoc (concat label sep (int-to-string num))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2856 (symbol-value reftex-docstruct-symbol))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2857 (incf num))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2858 (setcdr cell num)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2859 (concat label sep (int-to-string num))))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2860
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2861 ;;; Referencing labels ------------------------------------------------------
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2862
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2863 ;; Help string for the reference label menu
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2864 (defconst reftex-select-label-prompt
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2865 "Select: [n]ext [p]revious [r]escan [ ]context e[x]tern [q]uit RET [?]HELP+more")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2866
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2867 (defconst reftex-select-label-help
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2868 " n / p Go to next/previous label (Cursor motion works as well)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2869 C-c C-n/p Go to next/previous section heading.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2870 b / l Jump back to previous selection / Reuse last referenced label
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2871 C-s / C-r Search forward/backward. Use repeated C-s/C-r as in isearch.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2872 g / s Update menu / Switch label type
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2873 r / R Reparse document / Reparse entire document
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2874 x Switch to label menu of external document (with LaTeX package `xr')
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2875 t i c # % Toggle: [i]ncl. file borders, [t]able of contents, [c]ontext
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2876 [#] label counters, [%] labels in comments
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2877 SPC / f Show full context in other window / Toggle follow mode
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2878 v / . Toggle \\ref <-> \\vref / Show insertion point in other window
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2879 TAB Enter a label with completion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2880 q / RET Quit without referencing / Accept current label (also on mouse-2)")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2881
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2882 (defvar reftex-select-label-map nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2883 "Keymap used for *RefTeX Select* buffer, when selecting a label.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2884 This keymap can be used to configure the label selection process which is
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2885 started with the command \\[reftex-reference].")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2886
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2887 (defun reftex-select-label-mode ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2888 "Major mode for selecting a label in a LaTeX document.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2889 This buffer was created with RefTeX.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2890 It only has a meaningful keymap when you are in the middle of a
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2891 selection process.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2892 To select a label, move the cursor to it and press RET.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2893 Press `?' for a summary of important key bindings.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2894
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2895 During a selection process, these are the local bindings.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2896
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2897 \\{reftex-select-label-map}"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2898
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2899 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2900 (kill-all-local-variables)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2901 (make-local-hook 'pre-command-hook)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2902 (make-local-hook 'post-command-hook)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2903 (setq major-mode 'reftex-select-label-mode
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2904 mode-name "RefTeX Select Label")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2905 (when (syntax-table-p reftex-latex-syntax-table)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2906 (set-syntax-table reftex-latex-syntax-table))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2907 ;; We do not set a local map - reftex-select-item does this.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2908 (run-hooks 'reftex-select-label-mode-hook))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2909
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2910 (defun reftex-reference (&optional type no-insert cut)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2911 "Make a LaTeX reference. Look only for labels of a certain TYPE.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2912 With prefix arg, force to rescan buffer for labels. This should only be
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2913 necessary if you have recently entered labels yourself without using
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2914 reftex-label. Rescanning of the buffer can also be requested from the
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2915 label selection menu.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2916 The function returns the selected label or nil.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2917 If NO-INSERT is non-nil, do not insert \\ref command, just return label.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2918 When called with 2 C-u prefix args, disable magic word recognition."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2919
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2920 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2921
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2922 ;; check for active recursive edits
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2923 (reftex-check-recursive-edit)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2924
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2925 ;; Ensure access to scanning info and rescan buffer if prefix are is '(4)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2926 (reftex-access-scan-info current-prefix-arg)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2927
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2928 (unless type
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2929 ;; guess type from context
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2930 (if (and reftex-guess-label-type
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2931 (setq type (reftex-guess-label-type)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2932 (setq cut (cdr type)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2933 type (car type))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2934 (setq type (reftex-query-label-type))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2935
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2936 (let* ((varioref (if (reftex-typekey-check
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2937 type reftex-vref-is-default)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2938 "\\vref" "\\ref"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2939 (form "\\ref{%s}")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2940 label pair)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2941
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2942 ;; Have the user select a label
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2943 (set-marker reftex-select-return-marker (point))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2944 (setq pair (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2945 (reftex-offer-label-menu type)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2946 (reftex-ensure-compiled-variables)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2947 (set-marker reftex-select-return-marker nil)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2948 (setq label (car pair)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2949 type (cdr pair)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2950 form (or (cdr (assoc type reftex-typekey-to-format-alist))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2951 form))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2952
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2953 (if (and label
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2954 (not no-insert))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2955 (progn
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2956 (if cut (backward-delete-char cut))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2957
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2958 ;; remove ~ if we do already have a space
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2959 (when (and (= ?~ (string-to-char form))
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
2960 (member (preceding-char) '(?\ ?\t ?\n)))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2961 (setq form (substring form 1)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2962 ;; do we need to switch from \ref to \vref?
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2963 (when (string= varioref "\\vref")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2964 (while (string-match "\\\\ref{" form)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2965 (setq form (replace-match "\\vref{" t t form))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2966 ;; ok, insert the reference
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2967 (insert
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2968 (if reftex-format-ref-function
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2969 (funcall reftex-format-ref-function label form)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2970 (format form label label)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2971 (message ""))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2972 (message "Quit"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2973 ;; return the label
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2974 label))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2975
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2976 (defun reftex-guess-label-type ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2977 ;; Examine context to guess what a \ref might want to reference.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2978 (let ((words reftex-words-to-typekey-alist)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2979 (case-fold-search t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2980 (bound (max (point-min) (- (point) 35)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2981 matched cell)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2982 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2983 (while (and (setq cell (pop words))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2984 (not (setq matched
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2985 (re-search-backward (car cell) bound t))))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2986 (if matched
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2987 (cons (cdr cell) (- (match-end 0) (match-end 1)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2988 nil)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2989
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2990 (defun reftex-offer-label-menu (typekey)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2991 ;; Offer a menu with the appropriate labels. Return (label . typekey).
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2992 (let* ((buf (current-buffer))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2993 (xr-data (assq 'xr (symbol-value reftex-docstruct-symbol)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2994 (xr-alist (cons (cons "" (buffer-file-name)) (nth 1 xr-data)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2995 (xr-index 0)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2996 (here-I-am (car (reftex-where-am-I)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2997 (here-I-am1 here-I-am)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2998 (toc (reftex-typekey-check typekey reftex-label-menu-flags 0))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2999 (files (reftex-typekey-check typekey reftex-label-menu-flags 7))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3000 (context (not (reftex-typekey-check
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3001 typekey reftex-label-menu-flags 3)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3002 (counter (reftex-typekey-check
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3003 typekey reftex-label-menu-flags 2))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3004 (follow (reftex-typekey-check
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3005 typekey reftex-label-menu-flags 4))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3006 (commented (nth 5 reftex-label-menu-flags))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3007 (prefix "")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3008 selection-buffers
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3009 offset rtn key data last-data entry)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3010
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3011 (setq entry (cons nil nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3012
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3013 (unwind-protect
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3014 (catch 'exit
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3015 (while t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3016 (save-window-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3017 (delete-other-windows)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3018 (setq reftex-call-back-to-this-buffer buf
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3019 reftex-latex-syntax-table (syntax-table))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3020 (let ((default-major-mode 'reftex-select-label-mode))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3021 (if reftex-use-multiple-selection-buffers
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3022 (switch-to-buffer-other-window
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3023 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3024 (set-buffer buf)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3025 (reftex-make-selection-buffer-name typekey)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3026 (switch-to-buffer-other-window "*RefTeX Select*")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3027 (reftex-erase-buffer)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3028 (unless (eq major-mode 'reftex-select-label-mode)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3029 (reftex-select-label-mode))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3030 (add-to-list 'selection-buffers (current-buffer))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3031 (setq truncate-lines t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3032 (setq mode-line-format
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3033 (list "---- " 'mode-line-buffer-identification
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3034 " " 'varioref
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3035 " " (abbreviate-file-name
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3036 (buffer-file-name buf))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3037 " -%-"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3038 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3039 ((= 0 (buffer-size))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3040 (let ((buffer-read-only nil))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3041 (message "Creating Selection Buffer...")
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3042 (setq offset (reftex-insert-docstruct
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3043 typekey buf toc t files context counter
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3044 commented
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3045 (or here-I-am offset) prefix nil))))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3046 (here-I-am
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3047 (setq offset (reftex-get-offset buf here-I-am typekey)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3048 (t (setq offset t)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3049 (setq buffer-read-only t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3050 (setq offset (or offset t))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3051
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3052 (setq here-I-am nil) ; turn off determination of offset
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3053 (setq rtn
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3054 (reftex-select-item
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3055 reftex-select-label-prompt
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3056 reftex-select-label-help
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3057 reftex-select-label-map
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3058 offset
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3059 'reftex-show-label-location follow))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3060 (setq key (car rtn)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3061 data (nth 1 rtn)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3062 last-data (nth 2 rtn)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3063 offset t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3064 (unless key (throw 'exit nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3065 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3066 ((eq key ?g)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3067 ;; update buffer
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3068 (reftex-erase-buffer))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3069 ((or (eq key ?r)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3070 (eq key ?R))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3071 ;; rescan buffer
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3072 (reftex-erase-buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3073 (reftex-reparse-document buf last-data key))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3074 ((eq key ?c)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3075 ;; toggle context mode
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3076 (reftex-erase-buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3077 (setq context (not context)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3078 ((eq key ?s)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3079 ;; switch type
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3080 (setq here-I-am here-I-am1)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3081 (setq typekey (reftex-query-label-type)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3082 ((eq key ?t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3083 ;; toggle table of contents display
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3084 (reftex-erase-buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3085 (setq toc (not toc)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3086 ((eq key ?i)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3087 ;; toggle display of included file borders
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3088 (reftex-erase-buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3089 (setq files (not files)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3090 ((eq key ?#)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3091 ;; toggle counter display
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3092 (reftex-erase-buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3093 (setq counter (not counter)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3094 ((eq key ?%)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3095 ;; toggle display of commented labels
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3096 (reftex-erase-buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3097 (setq commented (not commented)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3098 ((eq key ?l)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3099 ;; reuse the last referenced label again
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3100 (setq entry reftex-last-used-reference)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3101 (throw 'exit t))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3102 ((eq key ?x)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3103 ;; select an external document
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3104 (setq xr-index (reftex-select-external-document
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3105 xr-alist xr-index))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3106 (setq buf (or (reftex-get-file-buffer-force
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3107 (cdr (nth xr-index xr-alist)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3108 (error "Cannot switch document"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3109 prefix (or (car (nth xr-index xr-alist)) ""))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3110 (set-buffer buf)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3111 (reftex-access-scan-info))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3112 ((stringp key)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3113 (setq entry
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3114 (or (assoc key (symbol-value reftex-docstruct-symbol))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3115 (list key typekey)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3116 (throw 'exit t))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3117 (t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3118 (set-buffer buf)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3119 (if data
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3120 (progn
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3121 (setq entry data)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3122 (setq reftex-last-used-reference entry))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3123 (setq entry nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3124 (throw 'exit t))))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3125 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3126 (while reftex-buffers-with-changed-invisibility
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3127 (set-buffer (car (car reftex-buffers-with-changed-invisibility)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3128 (setq buffer-invisibility-spec
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3129 (cdr (pop reftex-buffers-with-changed-invisibility)))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3130 (mapcar (function (lambda (buf)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3131 (and (buffer-live-p buf)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3132 (bury-buffer buf))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3133 selection-buffers)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3134 (reftex-kill-temporary-buffers))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3135 (cons (if (nth 0 entry) (concat prefix (nth 0 entry)) nil)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3136 (nth 1 entry))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3137
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3138 (defun reftex-select-external-document (xr-alist xr-index)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3139 ;; Return index of an external document.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3140 (let* ((len (length xr-alist)) (highest (1- (+ ?0 len)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3141 (prompt (format "[%c-%c] Select TAB: Read prefix with completion"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3142 ?0 highest))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3143 key prefix)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3144 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3145 ((= len 1)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3146 (message "No external documents available")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3147 (ding) (sit-for 1) 0)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3148 ((= len 2)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3149 (- 1 xr-index))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3150 (t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3151 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3152 (let* ((length (apply 'max (mapcar
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3153 (lambda(x) (length (car x))) xr-alist)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3154 (fmt (format " [%%c] %%-%ds %%s\n" length))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3155 (n (1- ?0)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3156 (setq key
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3157 (reftex-select-with-char
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3158 prompt
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3159 (concat
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3160 "SELECT EXTERNAL DOCUMENT\n------------------------\n"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3161 (mapconcat
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3162 (function
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3163 (lambda (x)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3164 (format fmt (incf n) (or (car x) "")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3165 (abbreviate-file-name (cdr x)))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3166 xr-alist ""))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3167 nil t))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3168 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3169 ((and (>= key ?0) (<= key highest)) (- key ?0))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3170 ((= key ?\C-i)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3171 (setq prefix (completing-read "Prefix: " xr-alist nil t))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3172 (- len (length (memq (assoc prefix xr-alist) xr-alist))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3173 (t (error "Illegal document selection [%c]" key)))))))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3174
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3175 (defun reftex-reparse-document (&optional buffer data key)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3176 ;; Rescan the document.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3177 (save-window-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3178 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3179 (if buffer
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3180 (if (not (bufferp buffer))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3181 (error "No such buffer %s" (buffer-name buffer))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3182 (set-buffer buffer)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3183 (let ((arg (if (eq key ?R) '(16) '(4)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3184 (file (nth 3 data)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3185 (reftex-access-scan-info arg file)))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3186
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3187 (defun reftex-make-selection-buffer-name (type &optional index)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3188 ;; Make unique name for a selection buffer.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3189 (format " *RefTeX[%s][%d]*"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3190 type (or index (get reftex-docstruct-symbol ':master-index) 0)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3191
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3192 (defun reftex-get-offset (buf here-am-I &optional typekey toc file)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3193 ;; Find the correct offset data, like insert-docstruct would, but faster.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3194 ;; Buffer BUF knows the correct docstruct to use.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3195 ;; Basically this finds the first docstruct entry after HERE-I-AM which
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3196 ;; is of allowed type. The optional arguments specify what is allowed.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3197 (catch 'exit
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3198 (save-excursion
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3199 (set-buffer buf)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3200 (reftex-access-scan-info)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3201 (let* ((rest (memq here-am-I (symbol-value reftex-docstruct-symbol)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3202 entry)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3203 (while (setq entry (pop rest))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3204 (if (or (and typekey
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3205 (stringp (car entry))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3206 (or (equal typekey " ")
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3207 (equal typekey (nth 1 entry))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3208 (and toc (eq (car entry) 'toc))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3209 (and file
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3210 (memq (car entry) '(bof eof file-error))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3211 (throw 'exit entry)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3212 nil))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3213
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3214 (defun reftex-insert-docstruct
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3215 (typekey0 buf toc labels files context counter show-commented
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3216 here-I-am xr-prefix toc-buffer)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3217 ;; Insert an excerpt of the docstruct list.
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3218 ;; Return the data property of the entry corresponding to HERE-I-AM.
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3219 ;; TYPEKEY0 indicated which labels to put into the list.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3220 ;; BUF is the buffer which has the correct docstruct-symbol.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3221 ;; LABELS non-nil meand to include labels into the list.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3222 ;; FILES non-nil menas to display file boundaries.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3223 ;; CONTEXT non-nil meand to include label context.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3224 ;; COUNTER means to count the labels.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3225 ;; SHOW-COMMENTED meand to include also labels which are commented out.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3226 ;; HERE-I-AM is a member of the docstruct list. The function will return
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3227 ;; a used member near to this one, as a possible starting point.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3228 ;; XR-PREFIX is the prefix to put in front of labels.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3229 ;; TOC-BUFFER means this is to fill the toc buffer.
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3230 (let* ((font (reftex-use-fonts))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3231 (cnt 0)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3232 (index -1)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3233 (toc-indent " ")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3234 (label-indent
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3235 (concat "> "
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3236 (if toc (make-string (* 7 reftex-level-indent) ?\ ) "")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3237 (context-indent
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3238 (concat ". "
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3239 (if toc (make-string (* 7 reftex-level-indent) ?\ ) "")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3240 (mouse-face
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3241 (if (memq reftex-highlight-selection '(mouse both))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3242 reftex-mouse-selected-face
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3243 nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3244 (label-face (reftex-verified-face reftex-label-face
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3245 'font-lock-constant-face
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3246 'font-lock-reference-face))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3247 all cell text label typekey note comment master-dir-re
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3248 offset from to docstruct-symbol)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3249
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3250 ;; Pop to buffer buf to get the correct buffer-local variables
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3251 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3252 (set-buffer buf)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3253
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3254 ;; Ensure access to scanning info
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3255 (reftex-access-scan-info)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3256
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3257 (setq docstruct-symbol reftex-docstruct-symbol
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3258 all (symbol-value reftex-docstruct-symbol)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3259 reftex-active-toc nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3260 master-dir-re
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3261 (concat "\\`" (regexp-quote
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3262 (file-name-directory (reftex-TeX-master-file))))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3263
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3264 (set (make-local-variable 'reftex-docstruct-symbol) docstruct-symbol)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3265 (set (make-local-variable 'reftex-prefix)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3266 (cdr (assoc typekey0 reftex-typekey-to-prefix-alist)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3267 (if (equal reftex-prefix " ") (setq reftex-prefix nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3268
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3269 ;; Walk the docstruct and insert the appropriate stuff
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3270 (while (setq cell (pop all))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3271
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3272 (incf index)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3273 (setq from (point))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3274
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3275 (if (eq cell here-I-am) (setq offset 'attention))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3276
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3277 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3278
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3279 ((memq (car cell) '(bib thebib label-numbers appendix
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3280 master-dir bibview-cache is-multi xr xr-doc)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3281 ;; These are currently ignored
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3282
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3283 ((memq (car cell) '(bof eof file-error))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3284 ;; Beginning or end of a file
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3285 (when files
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3286 (if (eq offset 'attention) (setq offset cell))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3287 (insert
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3288 " File " (if (string-match master-dir-re (nth 1 cell))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3289 (substring (nth 1 cell) (match-end 0))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3290 (nth 1 cell))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3291 (cond ((eq (car cell) 'bof) " starts here\n")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3292 ((eq (car cell) 'eof) " ends here\n")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3293 ((eq (car cell) 'file-error) " was not found\n")))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3294 (setq to (point))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3295 (when font
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3296 (put-text-property from to
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3297 'face reftex-file-boundary-face))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3298 (when toc-buffer
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3299 (if mouse-face
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3300 (put-text-property from (1- to)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3301 'mouse-face mouse-face))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3302 (put-text-property from to ':data cell))))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3303
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3304 ((eq (car cell) 'toc)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3305 ;; a table of contents entry
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3306 (when toc
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3307 (if (eq offset 'attention) (setq offset cell))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3308 (setq reftex-active-toc cell)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3309 (insert (concat toc-indent (nth 2 cell) "\n"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3310 (setq to (point))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3311 (when font
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3312 (put-text-property from to
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3313 'face reftex-section-heading-face))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3314 (when toc-buffer
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3315 (if mouse-face
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3316 (put-text-property from (1- to)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3317 'mouse-face mouse-face))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3318 (put-text-property from to ':data cell))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3319 (goto-char to)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3320
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3321 ((stringp (car cell))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3322 ;; a label
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3323 (when (null (nth 2 cell))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3324 ;; No context yet. Quick update.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3325 (setcdr cell (cdr (reftex-label-info-update cell)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3326 (put docstruct-symbol 'modified t))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3327
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3328 (setq label (car cell)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3329 typekey (nth 1 cell)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3330 text (nth 2 cell)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3331 comment (nth 4 cell)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3332 note (nth 5 cell))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3333
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3334 (when (and labels
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3335 (or (string= typekey typekey0) (string= typekey0 " "))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3336 (or show-commented (null comment)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3337
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3338 ;; Yes we want this one
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3339 (incf cnt)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3340 (if (eq offset 'attention) (setq offset cell))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3341
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3342 (setq label (concat xr-prefix label))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3343 (when comment (setq label (concat "% " label)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3344 (insert label-indent label)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3345 (when font
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3346 (setq to (point))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3347 (put-text-property
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3348 (- (point) (length label)) to
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3349 'face (if comment
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3350 'font-lock-comment-face
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3351 label-face))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3352 (goto-char to))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3353
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3354 (insert (if counter (format " (%d) " cnt) "")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3355 (if comment " LABEL IS COMMENTED OUT " "")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3356 (if (stringp note) (concat " " note) "")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3357 "\n")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3358 (setq to (point))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3359
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3360 (when context
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3361 (insert context-indent text "\n")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3362 (setq to (point)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3363 (put-text-property from to ':data cell)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3364 (when mouse-face
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3365 (put-text-property from (1- to)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3366 'mouse-face mouse-face))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3367 (goto-char to)))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3368
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3369 (when (reftex-refontify)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3370 ;; we need to fontify the buffer
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3371 (reftex-fontify-select-label-buffer buf))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3372 (run-hooks 'reftex-display-copied-context-hook)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3373 offset))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3374
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3375 (defun reftex-find-start-point (fallback &rest locations)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3376 ;; Set point to the first available LOCATION. When a LOCATION is a list,
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3377 ;; search for such a ':data text property. When it is an integer,
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3378 ;; use is as line number. FALLBACK is a buffer position used if everything
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3379 ;; else fails.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3380 (catch 'exit
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3381 (goto-char (point-min))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3382 (let (loc pos)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3383 (while locations
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3384 (setq loc (pop locations))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3385 (cond
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3386 ((null loc))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3387 ((listp loc)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3388 (setq pos (text-property-any (point-min) (point-max) ':data loc))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3389 (when pos
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3390 (goto-char pos)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3391 (throw 'exit t)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3392 ((integerp loc)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3393 (when (<= loc (count-lines (point-min) (point-max)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3394 (goto-line loc)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3395 (throw 'exit t)))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3396 (goto-char fallback))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3397
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3398 (defun reftex-query-label-type ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3399 ;; Ask for label type
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3400 (let ((key (reftex-select-with-char
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3401 reftex-type-query-prompt reftex-type-query-help 3)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3402 (unless (member (char-to-string key) reftex-typekey-list)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3403 (error "No such label type: %s" (char-to-string key)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3404 (char-to-string key)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3405
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3406 (defun reftex-show-label-location (data forward no-revisit
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3407 &optional stay error)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3408 ;; View the definition site of a label in another window.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3409 ;; DATA is an entry from the docstruct list.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3410 ;; FORWARD indicates if the label is likely forward from current point.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3411 ;; NO-REVISIT means do not load a file to show this label.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3412 ;; STAY means leave the new window selected.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3413 ;; ERROR means throw an error exception when the label cannot be found.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3414 ;; If ERROR is nil, the return value of this function indicates success.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3415 (let* ((this-window (selected-window))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3416 (errorf (if error 'error 'message))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3417 label file buffer re found)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3418
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3419 (catch 'exit
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3420 (setq label (nth 0 data)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3421 file (nth 3 data))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3422
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3423 (unless file
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3424 (funcall errorf "Unknown label - reparse might help")
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3425 (throw 'exit nil))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3426
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3427 ;; Goto the file in another window
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3428 (setq buffer
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3429 (if no-revisit
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3430 (reftex-get-buffer-visiting file)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3431 (reftex-get-file-buffer-force
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3432 file (not reftex-keep-temporary-buffers))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3433 (if buffer
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3434 ;; good - the file is available
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3435 (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
3436 ;; we have got a problem here. The file does not exist.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3437 ;; Let' get out of here..
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3438 (funcall errorf "Label %s not found" label)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3439 (throw 'exit nil))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3440
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3441 ;; search for that label
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3442 (setq re (format reftex-find-label-regexp-format (regexp-quote label)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3443 (setq found
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3444 (if forward
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3445 (re-search-forward re nil t)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3446 (re-search-backward re nil t)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3447 (unless found
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3448 (goto-char (point-min))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3449 (unless (setq found (re-search-forward re nil t))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3450 ;; Ooops. Must be in a macro with distributed args.
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3451 (setq found
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3452 (re-search-forward
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3453 (format reftex-find-label-regexp-format2
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3454 (regexp-quote label)) nil t))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3455 (if (match-end 3)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3456 (progn
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3457 (reftex-highlight 0 (match-beginning 3) (match-end 3))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3458 (reftex-show-entry (match-beginning 3) (match-end 3))
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
3459 (recenter '(4))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3460 (unless stay (select-window this-window)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3461 (select-window this-window)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3462 (funcall errorf "Label %s not found" label))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3463 found)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3464
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3465 (defun reftex-show-entry (beg-hlt end-hlt)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3466 ;; Show entry if point is hidden
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3467 (let* ((n (/ (window-height) 2))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3468 (beg (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3469 (re-search-backward "[\n\r]" nil 1 n) (point)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3470 (end (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3471 (re-search-forward "[\n\r]" nil 1 n) (point))))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3472 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3473 ((and (boundp 'buffer-invisibility-spec) buffer-invisibility-spec
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3474 (get-char-property (1+ beg-hlt) 'invisible))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3475 ;; Invisible with text properties. That is easy to change.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3476 (push (cons (current-buffer) buffer-invisibility-spec)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3477 reftex-buffers-with-changed-invisibility)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3478 (setq buffer-invisibility-spec nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3479 ((string-match "\r" (buffer-substring beg end))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3480 ;; Invisible with selective display. We need to copy it.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3481 (let ((string (buffer-substring-no-properties beg end)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3482 (switch-to-buffer "*RefTeX Context Copy*")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3483 (setq buffer-read-only nil)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3484 (erase-buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3485 (insert string)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3486 (subst-char-in-region (point-min) (point-max) ?\r ?\n t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3487 (goto-char (- beg-hlt beg))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3488 (reftex-highlight 0 (1+ (- beg-hlt beg)) (1+ (- end-hlt beg)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3489 (if (reftex-refontify)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3490 (when (or (not (eq major-mode 'latex-mode))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3491 (not font-lock-mode))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3492 (latex-mode)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3493 (run-hook-with-args
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3494 'reftex-pre-refontification-functions
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3495 reftex-call-back-to-this-buffer 'reftex-hidden)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3496 (turn-on-font-lock))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3497 (when (or (not (eq major-mode 'fundamental-mode))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3498 font-lock-mode)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3499 (fundamental-mode)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3500 (run-hooks 'reftex-display-copied-context-hook)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3501 (setq buffer-read-only t))))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3502
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3503 ;;; =========================================================================
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3504 ;;;
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3505 ;;; Table of contents
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3506
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3507 ;; We keep at most one *toc* buffer - it is easy to make them
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3508
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3509 (defvar reftex-toc-map (make-sparse-keymap)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3510 "Keymap used for *toc* buffer.")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3511
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3512 (defun reftex-toc-mode ()
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3513 "Major mode for managing Table of Contents for LaTeX files.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3514 This buffer was created with RefTeX.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3515 Press `?' for a summary of important key bindings.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3516
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3517 Here are all local bindings.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3518
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3519 \\{reftex-toc-map}"
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3520 (interactive)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3521 (kill-all-local-variables)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3522 (setq major-mode 'reftex-toc-mode
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3523 mode-name "RefTeX Table of Contents")
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3524 (use-local-map reftex-toc-map)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3525 (set (make-local-variable 'revert-buffer-function) 'reftex-toc-revert)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3526 (setq truncate-lines t)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3527 (make-local-hook 'post-command-hook)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3528 (make-local-hook 'pre-command-hook)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3529 (make-local-variable 'reftex-last-follow-point)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3530 (add-hook 'post-command-hook 'reftex-toc-post-command-hook nil t)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3531 (add-hook 'pre-command-hook 'reftex-toc-pre-command-hook nil t)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3532 (run-hooks 'reftex-toc-mode-hook))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3533
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3534 (defvar reftex-last-toc-master nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3535 "Stores the name of the tex file that `reftex-toc' was last run on.")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3536
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3537 (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
3538 "Stores the file name from which `reftex-toc' was called. For redo command.")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3539
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3540 (defvar reftex-last-window-height nil)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3541
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3542 (defvar reftex-toc-return-marker (make-marker)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3543 "Marker which makes it possible to return from toc to old position.")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3544
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3545 (defconst reftex-toc-help
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3546 " AVAILABLE KEYS IN TOC BUFFER
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3547 ============================
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3548 n / p next-line / previous-line
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3549 SPC Show the corresponding section of the LaTeX document.
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3550 TAB Goto the section and keep the *toc* window.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3551 RET Goto the section and hide the *toc* window (also on mouse-2).
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3552 q / Q Hide/Kill *toc* buffer, return to position of last reftex-toc command.
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3553 l c i Toggle display of [l]abels, [c]ontext, [i]nclude file borders.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3554 f / g Toggle follow mode on and off / Refresh *toc* buffer.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3555 r / R Reparse the LaTeX document / Reparse entire LaTeX document.
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3556 . In other window, show position from where `reftex-toc' was called.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3557 x Switch to TOC of external document (with LaTeX package `xr').")
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3558
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3559 (defun reftex-toc (&optional rebuild)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3560 "Show the table of contents for the current document.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3561 When called with a raw C-u prefix, rescan the document first."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3562
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3563 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3564
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3565 (if (or (not (string= reftex-last-toc-master (reftex-TeX-master-file)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3566 current-prefix-arg)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3567 (reftex-erase-buffer "*toc*"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3568
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3569 (setq reftex-last-toc-file (buffer-file-name))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3570 (setq reftex-last-toc-master (reftex-TeX-master-file))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3571
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3572 (set-marker reftex-toc-return-marker (point))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3573
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3574 ;; If follow mode is active, arrange to delay it one command
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3575 (if reftex-toc-follow-mode
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3576 (setq reftex-toc-follow-mode 1))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3577
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3578 ;; Ensure access to scanning info and rescan buffer if prefix are is '(4)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3579 (reftex-access-scan-info current-prefix-arg)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3580
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3581 (let* ((this-buf (current-buffer))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3582 (xr-data (assq 'xr (symbol-value reftex-docstruct-symbol)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3583 (xr-alist (cons (cons "" (buffer-file-name)) (nth 1 xr-data)))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3584 (here-I-am (if rebuild
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3585 (get 'reftex-toc ':reftex-data)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3586 (car (reftex-where-am-I))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3587 offset)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3588
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3589 (if (get-buffer-window "*toc*")
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3590 (select-window (get-buffer-window "*toc*"))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3591 (when (or (not reftex-toc-keep-other-windows)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3592 (< (window-height) (* 2 window-min-height)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3593 (delete-other-windows))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3594 (setq reftex-last-window-height (window-height)) ; remember
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3595 (split-window)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3596 (let ((default-major-mode 'reftex-toc-mode))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3597 (switch-to-buffer "*toc*")))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3598
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3599 (or (eq major-mode 'reftex-toc-mode) (reftex-toc-mode))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3600
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3601 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3602 ((= (buffer-size) 0)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3603 ;; buffer is empty - fill it with the table of contents
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3604 (message "Building *toc* buffer...")
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3605
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3606 (setq buffer-read-only nil)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3607 (insert (format
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3608 "TABLE-OF-CONTENTS on %s
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3609 SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [l]abels [f]ollow [x]r [?]Help
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3610 ------------------------------------------------------------------------------
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3611 " (abbreviate-file-name reftex-last-toc-master)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3612
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3613 (if (reftex-use-fonts)
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
3614 (put-text-property 1 (point) 'face reftex-toc-header-face))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3615 (put-text-property 1 (point) 'intangible t)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3616 (put-text-property 1 2 'xr-alist xr-alist)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3617
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3618 (setq offset
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3619 (reftex-insert-docstruct
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3620 " "
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3621 this-buf
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3622 t ; toc
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3623 reftex-toc-include-labels
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3624 reftex-toc-include-file-boundaries
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3625 reftex-toc-include-context
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3626 nil ; counter
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3627 nil ; commented
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3628 here-I-am "" t))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3629
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3630 (run-hooks 'reftex-display-copied-context-hook)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3631 (message "Building *toc* buffer...done.")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3632 (setq buffer-read-only t))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3633 (t
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3634 ;; Only compute the offset
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3635 (setq offset
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3636 (or (reftex-get-offset this-buf here-I-am
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3637 (if reftex-toc-include-labels " " nil)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3638 t
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3639 reftex-toc-include-file-boundaries)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3640 (reftex-last-assoc-before-elt
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3641 'toc here-I-am
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3642 (symbol-value reftex-docstruct-symbol))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3643 (put 'reftex-toc ':reftex-line 3)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3644 (goto-line 3)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3645 (beginning-of-line)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3646
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3647 ;; Find the correct starting point
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3648 (reftex-find-start-point (point) offset (get 'reftex-toc ':reftex-line))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3649 (setq reftex-last-follow-point (point))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3650
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3651 (defun reftex-toc-pre-command-hook ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3652 ;; used as pre command hook in *toc* buffer
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3653 (reftex-unhighlight 0)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3654 (reftex-unhighlight 1))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3655
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3656 (defun reftex-toc-post-command-hook ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3657 ;; used in the post-command-hook for the *toc* buffer
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3658 (when (get-text-property (point) ':data)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3659 (put 'reftex-toc ':reftex-data (get-text-property (point) ':data))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3660 (and (> (point) 1)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3661 (not (get-text-property (point) 'intangible))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3662 (memq reftex-highlight-selection '(cursor both))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3663 (reftex-highlight 1
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3664 (or (previous-single-property-change (1+ (point)) ':data)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3665 (point-min))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3666 (or (next-single-property-change (point) ':data)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3667 (point-max)))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3668 (if (integerp reftex-toc-follow-mode)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3669 ;; remove delayed action
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3670 (setq reftex-toc-follow-mode t)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3671 (and reftex-toc-follow-mode
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3672 (not (equal reftex-last-follow-point (point)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3673 ;; show context in other window
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3674 (setq reftex-last-follow-point (point))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3675 (condition-case nil
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3676 (reftex-toc-visit-location nil (not reftex-revisit-to-follow))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3677 (error t)))))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3678
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3679 (defun reftex-re-enlarge ()
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3680 ;; Enlarge windiw to a remembered size
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3681 (enlarge-window
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3682 (max 0 (- (or reftex-last-window-height (window-height))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3683 (window-height)))))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3684
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3685 (defun reftex-toc-show-help ()
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3686 "Show a summary of special key bindings."
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3687 (interactive)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3688 (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
3689 (princ reftex-toc-help))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3690 ;; 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
3691 (if reftex-toc-follow-mode
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3692 (setq reftex-toc-follow-mode 1)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3693
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3694 (defun reftex-toc-next (&optional arg)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3695 "Move to next selectable item."
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3696 (interactive "p")
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3697 (setq reftex-callback-fwd t)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3698 (or (eobp) (forward-char 1))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3699 (goto-char (or (next-single-property-change (point) ':data)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3700 (point))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3701 (defun reftex-toc-previous (&optional arg)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3702 "Move to previous selectable item."
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3703 (interactive "p")
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3704 (setq reftex-callback-fwd nil)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3705 (goto-char (or (previous-single-property-change (point) ':data)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3706 (point))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3707 (defun reftex-toc-toggle-follow ()
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3708 "Toggle follow (other window follows with context)."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3709 (interactive)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3710 (setq reftex-last-follow-point -1)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3711 (setq reftex-toc-follow-mode (not reftex-toc-follow-mode)))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3712 (defun reftex-toc-toggle-file-boundary ()
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3713 "Toggle inclusion of file boundaries in *toc* buffer."
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3714 (interactive)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3715 (setq reftex-toc-include-file-boundaries
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3716 (not reftex-toc-include-file-boundaries))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3717 (reftex-toc-revert))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3718 (defun reftex-toc-toggle-labels ()
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3719 "Toggle inclusion of labels in *toc* buffer."
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3720 (interactive)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3721 (setq reftex-toc-include-labels (not reftex-toc-include-labels))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3722 (reftex-toc-revert))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3723 (defun reftex-toc-toggle-context ()
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3724 "Toggle inclusion of label context in *toc* buffer.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3725 Label context is only displayed when the labels are there as well."
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3726 (interactive)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3727 (setq reftex-toc-include-context (not reftex-toc-include-context))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3728 (reftex-toc-revert))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3729 (defun reftex-toc-view-line ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3730 "View document location in other window."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3731 (interactive)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3732 (reftex-toc-visit-location))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3733 (defun reftex-toc-mouse-view-line (ev)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3734 "View document location in other window."
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3735 (interactive "e")
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3736 (mouse-set-point ev)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3737 (reftex-toc-visit-location))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3738 (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
3739 "Go to document location in other window. Hide the *toc* window."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3740 (interactive)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3741 (reftex-toc-visit-location 'hide))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3742 (defun reftex-toc-goto-line ()
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3743 "Go to document location in other window. *toc* window stays."
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3744 (interactive)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3745 (reftex-toc-visit-location t))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3746 (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
3747 "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
3748 (interactive "e")
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3749 (mouse-set-point ev)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3750 (reftex-toc-visit-location 'hide))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3751 (defun reftex-toc-show-calling-point ()
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3752 "Show point where reftex-toc was called from."
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3753 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3754 (let ((this-window (selected-window)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3755 (unwind-protect
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3756 (progn
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3757 (switch-to-buffer-other-window
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3758 (marker-buffer reftex-toc-return-marker))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3759 (goto-char (marker-position reftex-toc-return-marker))
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
3760 (recenter '(4)))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3761 (select-window this-window))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3762 (defun reftex-toc-quit ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3763 "Hide the *toc* window and do not move point."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3764 (interactive)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3765 (or (one-window-p) (delete-window))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3766 (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
3767 (reftex-re-enlarge)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3768 (goto-char (or (marker-position reftex-toc-return-marker) (point))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3769 (defun reftex-toc-quit-and-kill ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3770 "Kill the *toc* buffer."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3771 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3772 (kill-buffer "*toc*")
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3773 (or (one-window-p) (delete-window))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3774 (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
3775 (reftex-re-enlarge)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3776 (goto-char (marker-position reftex-toc-return-marker)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3777 (defun reftex-toc-rescan (&rest ignore)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3778 "Regenerate the *toc* buffer by reparsing file of section at point."
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3779 (interactive)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3780 (if reftex-enable-partial-scans
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3781 (let* ((data (get-text-property (point) ':data))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3782 (what (car data))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3783 (file (cond ((eq what 'toc) (nth 3 data))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3784 ((memq what '(eof bof file-error)) (nth 1 data))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3785 ((stringp what) (nth 3 data))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3786 (line (+ (count-lines (point-min) (point)) (if (bolp) 1 0))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3787 (if (not file)
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
3788 (error "Don't know which file to rescan. Try `R'")
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3789 (put 'reftex-toc ':reftex-line line)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3790 (switch-to-buffer-other-window
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3791 (reftex-get-file-buffer-force file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3792 (setq current-prefix-arg '(4))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3793 (reftex-toc t)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3794 (reftex-toc-Rescan))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3795 (reftex-kill-temporary-buffers))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3796 (defun reftex-toc-Rescan (&rest ignore)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3797 "Regenerate the *toc* buffer by reparsing the entire document."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3798 (interactive)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3799 (switch-to-buffer-other-window
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3800 (reftex-get-file-buffer-force reftex-last-toc-file))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3801 (setq current-prefix-arg '(16))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3802 (reftex-toc t))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3803 (defun reftex-toc-revert (&rest ignore)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3804 "Regenerate the *toc* from the internal lists."
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3805 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3806 (switch-to-buffer-other-window
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3807 (reftex-get-file-buffer-force reftex-last-toc-file))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3808 (reftex-erase-buffer "*toc*")
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3809 (setq current-prefix-arg nil)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3810 (reftex-toc t))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3811 (defun reftex-toc-external (&rest ignore)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3812 "Switch to table of contents of an external document."
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3813 (interactive)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3814 (let* ((old-buf (current-buffer))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3815 (xr-alist (get-text-property 1 'xr-alist))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3816 (xr-index (reftex-select-external-document
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3817 xr-alist 0)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3818 (switch-to-buffer-other-window (or (reftex-get-file-buffer-force
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3819 (cdr (nth xr-index xr-alist)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3820 (error "Cannot switch document")))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3821 (reftex-toc)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3822 (if (equal old-buf (current-buffer))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3823 (message "")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3824 (message "Switched document"))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3825
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3826 (defun reftex-toc-visit-location (&optional final no-revisit)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3827 ;; Visit the tex file corresponding to the toc entry on the current line.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3828 ;; If FINAL is t, stay there
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3829 ;; If FINAL is 'hide, hide the *toc* window.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3830 ;; Otherwise, move cursor back into *toc* window.
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3831 ;; NO-REVISIT means don't visit files, just use live biffers.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3832 ;; This function is pretty clever about finding back a section heading,
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3833 ;; even if the buffer is not live, or things like outline, x-symbol etc.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3834 ;; have been active.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3835
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3836 (let* ((toc (get-text-property (point) ':data))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3837 (toc-window (selected-window))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3838 show-window show-buffer match)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3839
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3840 (unless toc (error "Don't know which toc line to visit"))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3841
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3842 (cond
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3843
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3844 ((eq (car toc) 'toc)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3845 ;; a toc entry
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3846 (setq match (reftex-toc-find-section toc no-revisit)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3847
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3848 ((memq (car toc) '(bof eof))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3849 ;; A file entry
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3850 (setq match
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3851 (let ((where (car toc))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3852 (file (nth 1 toc)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3853 (if (or (not no-revisit) (reftex-get-buffer-visiting file))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3854 (progn
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3855 (switch-to-buffer-other-window
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3856 (reftex-get-file-buffer-force file nil))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3857 (goto-char (if (eq where 'bof) (point-min) (point-max))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3858 (message reftex-no-follow-message) nil))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3859
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3860 ((stringp (car toc))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3861 ;; a label
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3862 (setq match (reftex-show-label-location toc reftex-callback-fwd
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3863 no-revisit t))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3864
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3865 (setq show-window (selected-window)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3866 show-buffer (current-buffer))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3867
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3868 (unless match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3869 (select-window toc-window)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3870 (error "Cannot find location"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3871
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3872 (select-window toc-window)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3873
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3874 ;; use the `final' parameter to decide what to do next
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3875 (cond
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3876 ((eq final t)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3877 (reftex-unhighlight 0)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3878 (select-window show-window))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3879 ((eq final 'hide)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3880 (reftex-unhighlight 0)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3881 (or (one-window-p) (delete-window))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3882 (switch-to-buffer show-buffer)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3883 (reftex-re-enlarge))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3884 (t nil))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3885
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3886 (defun reftex-toc-find-section (toc &optional no-revisit)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3887 (let* ((file (nth 3 toc))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3888 (marker (nth 4 toc))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3889 (level (nth 5 toc))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3890 (literal (nth 7 toc))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3891 (emergency-point (nth 8 toc))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3892 (match
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3893 (cond
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3894 ((and (markerp marker) (marker-buffer marker))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3895 ;; Buffer is still live and we have the marker. Should be easy.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3896 (switch-to-buffer-other-window (marker-buffer marker))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3897 (goto-char (marker-position marker))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3898 (or (looking-at (regexp-quote literal))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3899 (looking-at (reftex-make-regexp-allow-for-ctrl-m literal))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3900 (looking-at (reftex-make-desperate-section-regexp literal))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3901 (looking-at (concat "\\\\"
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3902 (regexp-quote
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3903 (car
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3904 (rassq level
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3905 reftex-section-levels-all)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3906 "[[{]"))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3907 ((or (not no-revisit)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3908 (reftex-get-buffer-visiting file))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3909 ;; Marker is lost. Use the backup method.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3910 (switch-to-buffer-other-window
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3911 (reftex-get-file-buffer-force file nil))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3912 (goto-char (or emergency-point (point-min)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3913 (or (looking-at (regexp-quote literal))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3914 (let ((pos (point)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3915 (re-search-backward "\\`\\|[\r\n][ \t]*[\r\n]" nil t)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3916 (or (reftex-nearest-match (regexp-quote literal) pos)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3917 (reftex-nearest-match
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3918 (reftex-make-regexp-allow-for-ctrl-m literal) pos)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3919 (reftex-nearest-match
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3920 (reftex-make-desperate-section-regexp literal) pos)))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3921 (t (message reftex-no-follow-message) nil))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3922 (when match
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3923 (goto-char (match-beginning 0))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3924 (if (not (= (point) (point-max))) (recenter 1))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3925 (reftex-highlight 0 (match-beginning 0) (match-end 0) (current-buffer)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3926 match))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3927
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3928 (defun reftex-make-desperate-section-regexp (old)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3929 ;; Return a regexp which will still match a section statement even if
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3930 ;; x-symbol or isotex or the like have been at work in the mean time.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3931 (let* ((n (1+ (string-match "[[{]" old)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3932 (new (regexp-quote (substring old 0 (1+ (string-match "[[{]" old)))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3933 (old (substring old n)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3934 (while (string-match
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3935 "\\([\r\n]\\)\\|\\(\\`\\|[ \t\n\r]\\)\\([a-zA-Z0-9]+\\)\\([ \t\n\r]\\|}\\'\\)"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3936 old)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3937 (if (match-beginning 1)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3938 (setq new (concat new "[^\n\r]*[\n\r]"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3939 (setq new (concat new "[^\n\r]*" (match-string 3 old))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3940 (setq old (substring old (match-end 0))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3941 new))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3942
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3943 ;;; =========================================================================
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3944 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3945 ;;; BibTeX citations.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3946
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3947 ;; Variables and constants
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3948
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3949 ;; The history list of regular expressions used for citations
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3950 (defvar reftex-cite-regexp-hist nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3951
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3952 ;; 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
3953 (defconst reftex-citation-prompt
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3954 "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
3955
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3956 (defconst reftex-citation-help
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3957 " n / p Go to next/previous entry (Cursor motion works as well).
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3958 C-s / C-r Search forward/backward. Use repeated C-s/C-r as in isearch.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3959 g / r Start over with new regexp / Refine with additional regexp.
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3960 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
3961 f Toggle follow mode: Other window will follow with full db entry.
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3962 . Show insertion point.
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3963 q Quit without inserting \\cite macro into buffer.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3964 TAB Enter citation key with completion.
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3965 RET Accept current entry (also on mouse-2)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3966 a / A Put all entries into single \cite / into many cite commands.")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3967
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3968 (defvar reftex-select-bib-map nil
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3969 "Keymap used for *RefTeX Select* buffer, when selecting a BibTeX entry.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3970 This keymap can be used to configure the BibTeX selection process which is
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3971 started with the command \\[reftex-citation].")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3972
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3973 (defun reftex-select-bib-mode ()
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3974 "Major mode for selecting a citation key in a LaTeX document.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3975 This buffer was created with RefTeX.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3976 It only has a meaningful keymap when you are in the middle of a
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3977 selection process.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3978 In order to select a citation, move the cursor to it and press RET.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3979 Press `?' for a summary of important key bindings.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3980
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3981 During a selection process, these are the local bindings.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3982
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3983 \\{reftex-select-label-map}"
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3984 (interactive)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3985 (kill-all-local-variables)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3986 (make-local-hook 'pre-command-hook)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3987 (make-local-hook 'post-command-hook)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3988 (setq major-mode 'reftex-select-bib-mode
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3989 mode-name "RefTeX Select Bib")
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3990 ;; We do not set a local map - reftex-select-item does this.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3991 (run-hooks 'reftex-select-bib-mode-hook))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3992
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3993 ;; Find bibtex files
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3994
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3995 (defun reftex-get-bibfile-list ()
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3996 ;; Return list of bibfiles for current document.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3997 ;; When using the chapterbib or bibunits package you should either
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3998 ;; use the same database files everywhere, or separate parts using
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3999 ;; different databases into different files (included into the mater file).
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4000 ;; Then this function will return the applicable database files.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4001
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4002 ;; Ensure access to scanning info
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4003 (reftex-access-scan-info)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4004 (or
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4005 ;; Try inside this file (and its includes)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4006 (cdr (reftex-last-assoc-before-elt
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4007 'bib (list 'eof (buffer-file-name))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4008 (member (list 'bof (buffer-file-name))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4009 (symbol-value reftex-docstruct-symbol))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4010 ;; Try after the beginning of this file
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4011 (cdr (assq 'bib (member (list 'bof (buffer-file-name))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4012 (symbol-value reftex-docstruct-symbol))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4013 ;; Anywhere in the entire document
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4014 (cdr (assq 'bib (symbol-value reftex-docstruct-symbol)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4015 (error "\\bibliography statement missing or .bib files not found.")))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4016
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4017 ;; Find a certain reference in any of the BibTeX files.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4018
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4019 (defun reftex-pop-to-bibtex-entry (key file-list &optional mark-to-kill
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4020 highlight item return)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4021 ;; Find BibTeX KEY in any file in FILE-LIST in another window.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4022 ;; If MARK-TO-KILL is non-nil, mark new buffer to kill.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4023 ;; If HIGHLIGHT is non-nil, highlight the match.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4024 ;; If ITEM in non-nil, search for bibitem instead of database entry.
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
4025 ;; If RETURN is non-nil, just return the entry.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4026
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4027 (let* ((re
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4028 (if item
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4029 (concat "\\\\bibitem\\(\\[[^]]*\\]\\)?{" (regexp-quote key) "}")
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4030 (concat "@[a-zA-Z]+[ \t\n\r]*[{(][ \t\n\r]*" (regexp-quote key)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4031 "[, \t\r\n}]")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4032 (window-conf (current-window-configuration))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4033 file buf)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4034
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4035 (catch 'exit
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4036 (switch-to-buffer-other-window (current-buffer))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4037 (while file-list
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4038 (setq file (car file-list)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4039 file-list (cdr file-list))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4040 (unless (setq buf (reftex-get-file-buffer-force file mark-to-kill))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4041 (error "No such file %s" file))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4042 (switch-to-buffer buf)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4043 (widen)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4044 (goto-char (point-min))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4045 (when (re-search-forward re nil t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4046 (goto-char (match-beginning 0))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4047 (when return
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4048 ;; Just return the relevant entry
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
4049 (if item (goto-char (match-end 0)))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
4050 (setq return (buffer-substring
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
4051 (point) (reftex-end-of-bib-entry item)))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4052 (set-window-configuration window-conf)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4053 (throw 'exit return))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4054 (recenter 0)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4055 (if highlight
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4056 (reftex-highlight 0 (match-beginning 0) (match-end 0)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4057 (throw 'exit (selected-window))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4058 (set-window-configuration window-conf)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4059 (if item
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4060 (error "No \\bibitem with citation key %s" key)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4061 (error "No BibTeX entry with citation key %s" key)))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4062
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
4063 (defun reftex-end-of-bib-entry (item)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
4064 (save-excursion
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
4065 (condition-case nil
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
4066 (if item
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
4067 (progn (end-of-line)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
4068 (re-search-forward
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
4069 "\\\\bibitem\\|\\end{thebibliography}")
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
4070 (1- (match-beginning 0)))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
4071 (progn (forward-list 1) (point)))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
4072 (error (min (point-max) (+ 300 (point)))))))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
4073
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4074 ;; Parse bibtex buffers
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4075
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4076 (defun reftex-extract-bib-entries (buffers)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4077 ;; Extract bib entries which match regexps from BUFFERS.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4078 ;; BUFFERS is a list of buffers or file names.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4079 ;; Return list with entries."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4080 (let* (re-list first-re rest-re
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4081 (buffer-list (if (listp buffers) buffers (list buffers)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4082 found-list entry buffer1 buffer alist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4083 key-point start-point end-point)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4084
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4085 ;; Read a regexp, completing on known citation keys.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4086 (setq re-list
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4087 (split-string
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4088 (completing-read
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4089 "RegExp [ && RegExp...]: "
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
4090 (if reftex-mode
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
4091 (if (fboundp 'LaTeX-bibitem-list)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
4092 (LaTeX-bibitem-list)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
4093 (cdr (assoc 'bibview-cache
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
4094 (symbol-value reftex-docstruct-symbol))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
4095 nil)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4096 nil nil nil 'reftex-cite-regexp-hist)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4097 "[ \t]*&&[ \t]*"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4098
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4099 (setq first-re (car re-list) ; We'll use the first re to find things,
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4100 rest-re (cdr re-list)) ; the others to narrow down.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4101 (if (string-match "\\`[ \t]*\\'" first-re)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4102 (error "Empty regular expression"))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4103
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4104 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4105 (save-window-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4106
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4107 ;; Walk through all bibtex files
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4108 (while buffer-list
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4109 (setq buffer (car buffer-list)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4110 buffer-list (cdr buffer-list))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4111 (if (and (bufferp buffer)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4112 (buffer-live-p buffer))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4113 (setq buffer1 buffer)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4114 (setq buffer1 (reftex-get-file-buffer-force
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4115 buffer (not reftex-keep-temporary-buffers))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4116 (if (not buffer1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4117 (error "Cannot find BibTeX file %s" buffer)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4118 (message "Scanning bibliography database %s" buffer1))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4119
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4120 (set-buffer buffer1)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4121 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4122 (goto-char (point-min))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4123 (while (re-search-forward first-re nil t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4124 (catch 'search-again
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4125 (setq key-point (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4126 (unless (re-search-backward
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4127 "\\(\\`\\|[\n\r]\\)[ \t]*@\\([a-zA-Z]+\\)[ \t\n\r]*[{(]" nil t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4128 (throw 'search-again nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4129 (setq start-point (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4130 (goto-char (match-end 0))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4131 (condition-case nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4132 (up-list 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4133 (error (goto-char key-point)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4134 (throw 'search-again nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4135 (setq end-point (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4136
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4137 ;; Ignore @string, @comment and @c entries or things
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4138 ;; outside entries
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4139 (when (or (string= (downcase (match-string 2)) "string")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4140 (string= (downcase (match-string 2)) "comment")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4141 (string= (downcase (match-string 2)) "c")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4142 (< (point) key-point)) ; this means match not in {}
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4143 (goto-char key-point)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4144 (throw 'search-again nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4145
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4146 ;; Well, we have got a match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4147 (setq entry (concat
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4148 (buffer-substring start-point (point)) "\n"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4149
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4150 ;; Check if other regexp match as well
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4151 (setq re-list rest-re)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4152 (while re-list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4153 (unless (string-match (car re-list) entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4154 ;; nope - move on
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4155 (throw 'search-again nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4156 (pop re-list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4157
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4158 (setq alist (reftex-parse-bibtex-entry
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4159 nil start-point end-point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4160 (push (cons "&entry" entry) alist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4161
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4162 ;; check for crossref entries
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4163 (if (assoc "crossref" alist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4164 (setq alist
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4165 (append
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4166 alist (reftex-get-crossref-alist alist))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4167
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4168 ;; format the entry
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4169 (push (cons "&formatted" (reftex-format-bib-entry alist))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4170 alist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4171
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4172 ;; make key the first element
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4173 (push (reftex-get-bib-field "&key" alist) alist)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4174
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4175 ;; add it to the list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4176 (push alist found-list))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4177 (reftex-kill-temporary-buffers))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4178 (setq found-list (nreverse found-list))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4179
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4180 ;; Sorting
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4181 (cond
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4182 ((eq 'author reftex-sort-bibtex-matches)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4183 (sort found-list 'reftex-bib-sort-author))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4184 ((eq 'year reftex-sort-bibtex-matches)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4185 (sort found-list 'reftex-bib-sort-year))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4186 ((eq 'reverse-year reftex-sort-bibtex-matches)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4187 (sort found-list 'reftex-bib-sort-year-reverse))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4188 (t found-list))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4189
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4190 (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
4191 (let ((al1 (reftex-get-bib-names "author" e1))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4192 (al2 (reftex-get-bib-names "author" e2)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4193 (while (and al1 al2 (string= (car al1) (car al2)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4194 (pop al1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4195 (pop al2))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4196 (if (and (stringp (car al1))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4197 (stringp (car al2)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4198 (string< (car al1) (car al2))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4199 (not (stringp (car al1))))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4200
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4201 (defun reftex-bib-sort-year (e1 e2)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4202 (< (string-to-int (cdr (assoc "year" e1)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4203 (string-to-int (cdr (assoc "year" e2)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4204
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4205 (defun reftex-bib-sort-year-reverse (e1 e2)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4206 (> (string-to-int (or (cdr (assoc "year" e1)) "0"))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4207 (string-to-int (or (cdr (assoc "year" e2)) "0"))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4208
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4209 (defun reftex-get-crossref-alist (entry)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4210 ;; return the alist from a crossref entry
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4211 (let ((crkey (cdr (assoc "crossref" entry)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4212 start)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4213 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4214 (save-restriction
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4215 (widen)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4216 (if (re-search-forward
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4217 (concat "@\\w+[{(][ \t\n\r]*" (regexp-quote crkey)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4218 "[ \t\n\r]*,") nil t)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4219 (progn
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4220 (setq start (match-beginning 0))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4221 (condition-case nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4222 (up-list 1)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4223 (error nil))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4224 (reftex-parse-bibtex-entry nil start (point)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4225 nil)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4226
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4227 ;; Parse the thebibliography environment
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4228 (defun reftex-extract-bib-entries-from-thebibliography (file)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4229 ;; Extract bib-entries from the \begin{thebibliography} environment.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4230 ;; Parsing is not as good as for the BibTeX database stuff.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4231 ;; The environment should be located in file FILE.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4232
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4233 (let* (start end buf entries re re-list)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4234 (unless file
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4235 (error "Need file name to find thebibliography environment"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4236 (setq buf (reftex-get-file-buffer-force
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4237 file (not reftex-keep-temporary-buffers)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4238 (unless buf
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4239 (error "No such file %s" file))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4240 (message "Scanning thebibliography environment in %s" file)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4241
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4242 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4243 (set-buffer buf)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4244 (save-restriction
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4245 (widen)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4246 (goto-char (point-min))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4247 (if (re-search-forward
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4248 "\\(\\`\\|[\n\r]\\)[ \t]*\\\\begin{thebibliography}" nil t)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4249 (progn
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4250 (beginning-of-line 2)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4251 (setq start (point))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4252 (if (re-search-forward
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4253 "\\(\\`\\|[\n\r]\\)[ \t]*\\\\end{thebibliography}" nil t)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4254 (progn
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4255 (beginning-of-line 1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4256 (setq end (point))))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4257 (when (and start end)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4258 (setq entries
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4259 (mapcar 'reftex-parse-bibitem
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4260 (delete ""
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4261 (split-string
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4262 (buffer-substring-no-properties start end)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4263 "[ \t\n\r]*\\\\bibitem\\(\\[[^]]*]\\)*")))))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4264 (unless entries
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4265 (error "No bibitems found"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4266
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4267 (setq re-list (split-string
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4268 (read-string "RegExp [ && RegExp...]: "
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4269 nil 'reftex-cite-regexp-hist)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4270 "[ \t]*&&[ \t]*"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4271 (if (string-match "\\`[ \t]*\\'" (car re-list))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4272 (error "Empty regular expression"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4273
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4274 (while (and (setq re (pop re-list)) entries)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4275 (setq entries
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4276 (delq nil (mapcar
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4277 (function
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4278 (lambda (x)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4279 (if (string-match re (cdr (assoc "&entry" x)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4280 x nil)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4281 entries))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4282 (setq entries
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4283 (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4284 (lambda (x)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4285 (push (cons "&formatted" (reftex-format-bibitem x)) x)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4286 (push (reftex-get-bib-field "&key" x) x)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4287 x)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4288 entries))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4289
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4290 entries))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4291
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4292 ;; Parse and format individual entries
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4293
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4294 (defun reftex-get-bib-names (field entry)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4295 ;; Return a list with the author or editor names in ENTRY
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4296 (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
4297 (if (equal "" names)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4298 (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
4299 (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
4300 (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
4301 (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
4302 (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
4303 (while (string-match "^[ \t]+\\|[ \t]+$" names)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4304 (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
4305 (while (string-match "[ \t][ \t]+" names)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4306 (setq names (replace-match " " nil t names)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4307 (split-string names "\n")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4308
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4309 (defun reftex-parse-bibtex-entry (entry &optional from to)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4310 (let (alist key start field)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4311 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4312 (save-restriction
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4313 (if entry
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4314 (progn
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4315 (set-buffer (get-buffer-create " *RefTeX-scratch*"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4316 (fundamental-mode)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4317 (erase-buffer)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4318 (insert entry))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4319 (widen)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4320 (narrow-to-region from to))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4321 (goto-char (point-min))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4322
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4323 (if (re-search-forward
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
4324 "@\\(\\w+\\)[ \t\n\r]*[{(][ \t\n\r]*\\([^ \t\n\r,]+\\)" nil t)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4325 (setq alist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4326 (list
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4327 (cons "&type" (downcase (reftex-match-string 1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4328 (cons "&key" (reftex-match-string 2)))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4329 (while (re-search-forward "\\(\\w+\\)[ \t\n\r]*=[ \t\n\r]*" nil t)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4330 (setq key (downcase (reftex-match-string 1)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4331 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4332 ((= (following-char) ?{)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4333 (forward-char 1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4334 (setq start (point))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4335 (condition-case nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4336 (up-list 1)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4337 (error nil)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4338 ((= (following-char) ?\")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4339 (forward-char 1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4340 (setq start (point))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4341 (while (and (search-forward "\"" nil t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4342 (= ?\\ (char-after (- (point) 2))))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4343 (t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4344 (setq start (point))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4345 (re-search-forward "[ \t]*[\n\r,}]" nil 1)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4346 (setq field (buffer-substring-no-properties start (1- (point))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4347 ;; remove extra whitespace
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4348 (while (string-match "[\n\t\r]\\|[ \t][ \t]+" field)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4349 (setq field (replace-match " " nil t field)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4350 ;; remove leading garbage
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4351 (if (string-match "^[ \t{]+" field)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4352 (setq field (replace-match "" nil t field)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4353 ;; remove trailing garbage
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4354 (if (string-match "[ \t}]+$" field)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4355 (setq field (replace-match "" nil t field)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4356 (push (cons key field) alist))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4357 alist))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4358
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4359 (defun reftex-get-bib-field (fieldname entry &optional format)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4360 ;; Extract the field FIELDNAME from an ENTRY
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4361 (let ((cell (assoc fieldname entry)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4362 (if cell
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4363 (if format
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4364 (format format (cdr cell))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4365 (cdr cell))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4366 "")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4367
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4368 (defun reftex-format-bib-entry (entry)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4369 ;; Format a BibTeX ENTRY so that it is nice to look at
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4370 (let*
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4371 ((auth-list (reftex-get-bib-names "author" entry))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4372 (authors (mapconcat 'identity auth-list ", "))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4373 (year (reftex-get-bib-field "year" entry))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4374 (title (reftex-get-bib-field "title" entry))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4375 (type (reftex-get-bib-field "&type" entry))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4376 (key (reftex-get-bib-field "&key" entry))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4377 (extra
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4378 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4379 ((equal type "article")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4380 (concat (reftex-get-bib-field "journal" entry) " "
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4381 (reftex-get-bib-field "volume" entry) ", "
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4382 (reftex-get-bib-field "pages" entry)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4383 ((equal type "book")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4384 (concat "book (" (reftex-get-bib-field "publisher" entry) ")"))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4385 ((equal type "phdthesis")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4386 (concat "PhD: " (reftex-get-bib-field "school" entry)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4387 ((equal type "mastersthesis")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4388 (concat "Master: " (reftex-get-bib-field "school" entry)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4389 ((equal type "inbook")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4390 (concat "Chap: " (reftex-get-bib-field "chapter" entry)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4391 ", pp. " (reftex-get-bib-field "pages" entry)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4392 ((or (equal type "conference")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4393 (equal type "incollection")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4394 (equal type "inproceedings"))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4395 (reftex-get-bib-field "booktitle" entry "in: %s"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4396 (t ""))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4397 (setq authors (reftex-truncate authors 30 t t))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4398 (when (reftex-use-fonts)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4399 (put-text-property 0 (length key) 'face
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4400 (reftex-verified-face reftex-label-face
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4401 'font-lock-constant-face
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4402 'font-lock-reference-face)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4403 key)
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4404 (put-text-property 0 (length authors) 'face reftex-bib-author-face
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4405 authors)
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4406 (put-text-property 0 (length year) 'face reftex-bib-year-face
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4407 year)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4408 (put-text-property 0 (length title) 'face reftex-bib-title-face
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4409 title)
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4410 (put-text-property 0 (length extra) 'face reftex-bib-extra-face
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4411 extra))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4412 (concat key "\n " authors " " year " " extra "\n " title "\n\n")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4413
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4414 (defun reftex-parse-bibitem (item)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4415 ;; Parse a \bibitem entry
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4416 (let ((key "") (text ""))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4417 (when (string-match "\\`{\\([^}]+\\)}\\([\001-\255]*\\)" item)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4418 (setq key (match-string 1 item)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4419 text (match-string 2 item)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4420 ;; Clean up the text a little bit
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4421 (while (string-match "[\n\r\t]\\|[ \t][ \t]+" text)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4422 (setq text (replace-match " " nil t text)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4423 (if (string-match "\\`[ \t]+" text)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4424 (setq text (replace-match "" nil t text)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4425 (list
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4426 (cons "&key" key)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4427 (cons "&text" text)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4428 (cons "&entry" (concat key " " text)))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4429
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4430 (defun reftex-format-bibitem (item)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4431 ;; Format a \bibitem entry so that it is (relatively) nice to look at.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4432 (let ((text (reftex-get-bib-field "&text" item))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4433 (key (reftex-get-bib-field "&key" item))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4434 (lines nil))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4435
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4436 ;; Wrap the text into several lines.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4437 (while (and (> (length text) 70)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4438 (string-match " " (substring text 60)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4439 (push (substring text 0 (+ 60 (match-beginning 0))) lines)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4440 (setq text (substring text (+ 61 (match-beginning 0)))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4441 (push text lines)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4442 (setq text (mapconcat 'identity (nreverse lines) "\n "))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4443
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4444 (when (reftex-use-fonts)
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4445 (put-text-property 0 (length text) 'face reftex-bib-author-face text))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4446 (concat key "\n " text "\n\n")))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4447
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4448 ;; Make a citation
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4449
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4450 ;;;###autoload
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4451 (defun reftex-citation (&optional no-insert)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
4452 "Make a citation using BibTeX database files.
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
4453 After prompting for a regular expression, scans the buffers with
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4454 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
4455 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
4456 to `reftex-cite-format' and inserted into the buffer.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4457 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
4458 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
4459 Thus, `aaaa&&bbb' matches entries which contain both `aaaa' and `bbb'.
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4460 While entering the regexp, completion on knows citation keys is possible.
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
4461 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
4462 command, it will add another key, ignoring the value of `reftex-cite-format'.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4463 When called with a numeric prefix, that many citations will be made and all
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
4464 put into the same \\cite command.
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4465 When called with just or two C-u as prefix, enforces rescan of buffer for
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4466 bibliography statement (e.g. if it was changed)."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4467
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4468 (interactive)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4469
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4470 ;; check for recursive edit
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4471 (reftex-check-recursive-edit)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4472
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4473 ;; This function may also be called outside reftex-mode.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4474 ;; Thus look for the scanning info only if in reftex-mode.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4475
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4476 (when reftex-mode
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4477 (reftex-access-scan-info current-prefix-arg))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4478
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4479 ;; Call reftex-do-citation, but protected
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4480 (unwind-protect
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4481 (reftex-do-citation current-prefix-arg no-insert)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4482 (reftex-kill-temporary-buffers)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4483
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4484 (defun reftex-do-citation (&optional arg no-insert)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4485 ;; This really does the work of reftex-citation.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4486
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4487 (let* ((format (reftex-figure-out-cite-format arg no-insert))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4488 (docstruct-symbol reftex-docstruct-symbol)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4489 (selected-entries (reftex-offer-bib-menu))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4490 (insert-entries selected-entries)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4491 entry string cite-view)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4492
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4493 (unless selected-entries (error "Quit"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4494
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4495 (if (stringp selected-entries)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4496 ;; Nonexistent entry
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4497 (setq selected-entries nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4498 insert-entries (list (list selected-entries
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4499 (cons "&key" selected-entries))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4500 ;; It makes sense to compute the cite-view strings.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4501 (setq cite-view t))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4502
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4503 (when (eq (car selected-entries) 'concat)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4504 ;; All keys go into a single command - we need to trick a little
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4505 (pop selected-entries)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4506 (let ((concat-keys (mapconcat 'car selected-entries ",")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4507 (setq insert-entries
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4508 (list (list concat-keys (cons "&key" concat-keys))))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4509
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4510 (unless no-insert
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4511
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4512 ;; We shall insert this into the buffer...
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4513 (message "Formatting...")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4514
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4515 (while (setq entry (pop insert-entries))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4516 ;; Format the citation and insert it
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4517 (setq string (if reftex-format-cite-function
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4518 (funcall reftex-format-cite-function
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4519 (reftex-get-bib-field "&key" entry)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4520 format)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4521 (reftex-format-citation entry format)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4522 (insert string))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4523
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4524 ;; Reposition cursor?
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4525 (when (string-match "\\?" string)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4526 (search-backward "?")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4527 (delete-char 1))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4528
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4529 ;; Tell AUCTeX
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
4530 (when (and reftex-mode
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
4531 (fboundp 'LaTeX-add-bibitems)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
4532 reftex-plug-into-AUCTeX)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4533 (apply 'LaTeX-add-bibitems (mapcar 'car selected-entries)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4534
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4535 ;; Produce the cite-view strings
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
4536 (when (and reftex-mode reftex-cache-cite-echo cite-view)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4537 (mapcar (lambda (entry)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4538 (reftex-make-cite-echo-string entry docstruct-symbol))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4539 selected-entries))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4540
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4541 (message ""))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4542
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4543 (set-marker reftex-select-return-marker nil)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4544 (reftex-kill-buffer "*RefTeX Select*")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4545
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4546 ;; Check if the prefix arg was numeric, and call recursively
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4547 (when (integerp arg)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4548 (if (> arg 1)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4549 (progn
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4550 (skip-chars-backward "}")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4551 (decf arg)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4552 (reftex-do-citation arg))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4553 (forward-char 1)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4554
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4555 ;; Return the citation key
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4556 (car (car selected-entries))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4557
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4558 (defun reftex-figure-out-cite-format (arg no-insert)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4559 ;; Check if there is already a cite command at point and change cite format
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4560 ;; in order to only add another reference in the same cite command.
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4561 (let ((macro (car (reftex-what-macro 1)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4562 (cite-format-value (reftex-get-cite-format))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4563 key format)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4564 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4565 (no-insert
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4566 ;; Format does not really matter because nothing will be inserted.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4567 (setq format "%l"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4568
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4569 ((and (stringp macro)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4570 (string-match "\\`\\\\cite\\|cite\\'" macro))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4571 ;; We are already inside a cite macro
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4572 (if (or (not arg) (not (listp arg)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4573 (setq format
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4574 (concat
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4575 (if (member (preceding-char) '(?\{ ?,)) "" ",")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4576 "%l"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4577 (if (member (following-char) '(?\} ?,)) "" ",")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4578 (setq format "%l")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4579 (t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4580 ;; Figure out the correct format
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4581 (setq format
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4582 (if (and (symbolp cite-format-value)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4583 (assq cite-format-value reftex-cite-format-builtin))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4584 (nth 2 (assq cite-format-value reftex-cite-format-builtin))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4585 cite-format-value))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4586 (when (listp format)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4587 (setq key
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4588 (reftex-select-with-char
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4589 "" (concat "SELECT A CITATION FORMAT\n\n"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4590 (mapconcat
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4591 (lambda (x)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4592 (format "[%c] %s %s" (car x)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4593 (if (> (car x) 31) " " "")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4594 (cdr x)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4595 format "\n"))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4596 (if (assq key format)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4597 (setq format (cdr (assq key format)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4598 (error "No citation format associated with key `%c'" key)))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4599 format))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4600
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4601 (defun reftex-get-cite-format ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4602 ;; Return the current citation format. Either the document-local value in
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4603 ;; reftex-cite-format-symbol, or the global value in reftex-cite-format.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4604 (if (and reftex-docstruct-symbol
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4605 (symbolp reftex-docstruct-symbol)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4606 (get reftex-docstruct-symbol 'reftex-cite-format))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4607 (get reftex-docstruct-symbol 'reftex-cite-format)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4608 reftex-cite-format))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4609
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4610 (defun reftex-offer-bib-menu ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4611 ;; Offer bib menu and return list of selected items
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4612
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4613 (let (found-list rtn key data selected-entries)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4614
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4615 (while
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4616 (not
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4617 (catch 'done
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4618 ;; Scan bibtex files
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4619 (setq found-list
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4620 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4621 ((assq 'bib (symbol-value reftex-docstruct-symbol))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4622 ;; using BibTeX database files.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4623 (reftex-extract-bib-entries (reftex-get-bibfile-list)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4624 ((assq 'thebib (symbol-value reftex-docstruct-symbol))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4625 ;; using thebibliography environment.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4626 (reftex-extract-bib-entries-from-thebibliography
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4627 (cdr (assq 'thebib (symbol-value reftex-docstruct-symbol)))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4628 (reftex-default-bibliography
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4629 (message "Using default bibliography")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4630 (reftex-extract-bib-entries reftex-default-bibliography))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4631 (t (error "No valid bibliography in this document, and no default available"))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4632
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4633 (unless found-list
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4634 (error "Sorry, no matches found"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4635
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4636 ;; Remember where we came from
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4637 (setq reftex-call-back-to-this-buffer (current-buffer))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4638 (set-marker reftex-select-return-marker (point))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4639
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4640 ;; Offer selection
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4641 (save-window-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4642 (delete-other-windows)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4643 (let ((default-major-mode 'reftex-select-bib-mode))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4644 (reftex-kill-buffer "*RefTeX Select*")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4645 (switch-to-buffer-other-window "*RefTeX Select*")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4646 (unless (eq major-mode 'reftex-select-bib-mode)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4647 (reftex-select-bib-mode))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4648 (let ((buffer-read-only nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4649 (erase-buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4650 (reftex-insert-bib-matches found-list)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4651 (setq buffer-read-only t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4652 (if (= 0 (buffer-size))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4653 (error "Sorry, no matches found"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4654 (setq truncate-lines t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4655 (goto-char 1)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4656 (while t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4657 (setq rtn
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4658 (reftex-select-item
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4659 reftex-citation-prompt
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4660 reftex-citation-help
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4661 reftex-select-bib-map
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4662 nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4663 'reftex-bibtex-selection-callback nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4664 (setq key (car rtn)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4665 data (nth 1 rtn))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4666 (unless key (throw 'done t))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4667 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4668 ((eq key ?g)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4669 ;; Start over
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4670 (throw 'done nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4671 ((eq key ?r)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4672 ;; Restrict with new regular expression
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4673 (setq found-list (reftex-restrict-bib-matches found-list))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4674 (let ((buffer-read-only nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4675 (erase-buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4676 (reftex-insert-bib-matches found-list))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4677 (goto-char 1))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4678 ((eq key ?A)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
4679 (debug)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4680 ;; Take all
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4681 (setq selected-entries found-list)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4682 (throw 'done t))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4683 ((eq key ?a)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4684 ;; Take all
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4685 (setq selected-entries (cons 'concat found-list))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4686 (throw 'done t))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4687 ((or (eq key ?\C-m)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4688 (eq key 'return))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4689 ;; Take selected
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4690 (setq selected-entries (if data (list data) nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4691 (throw 'done t))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4692 ((stringp key)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4693 ;; Got this one with completion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4694 (setq selected-entries key)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4695 (throw 'done t))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4696 (t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4697 (ding))))))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4698 selected-entries))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4699
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4700 (defun reftex-restrict-bib-matches (found-list)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4701 ;; Limit FOUND-LIST with more regular expressions
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4702 (let ((re-list (split-string (read-string
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4703 "RegExp [ && RegExp...]: "
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4704 nil 'reftex-cite-regexp-hist)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4705 "[ \t]*&&[ \t]*"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4706 (found-list-r found-list)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4707 re)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4708 (while (setq re (pop re-list))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4709 (setq found-list-r
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4710 (delq nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4711 (mapcar
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4712 (lambda (x)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4713 (if (string-match
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4714 re (cdr (assoc "&entry" x)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4715 x
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4716 nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4717 found-list-r))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4718 (if found-list-r
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4719 found-list-r
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4720 (ding)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4721 found-list)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4722
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4723 (defun reftex-insert-bib-matches (list)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4724 ;; Insert the bib matches and number them correctly
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4725 (let ((mouse-face
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4726 (if (memq reftex-highlight-selection '(mouse both))
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4727 reftex-mouse-selected-face
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4728 nil))
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4729 tmp len)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4730 (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4731 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4732 (lambda (x)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4733 (setq tmp (cdr (assoc "&formatted" x))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4734 len (length tmp))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4735 (put-text-property 0 len ':data x tmp)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4736 (put-text-property 0 (1- len) 'mouse-face mouse-face tmp)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4737 (insert tmp)))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4738 list))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4739 (run-hooks 'reftex-display-copied-context-hook))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4740
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4741 (defun reftex-format-names (namelist n)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4742 (let (last (len (length namelist)))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4743 (cond
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4744 ((< len 1) "")
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4745 ((= 1 len) (car namelist))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4746 ((> 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
4747 (t
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4748 (setq n (min len n)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4749 last (nth (1- n) namelist))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4750 (setcdr (nthcdr (- n 2) namelist) nil)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4751 (concat
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4752 (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
4753 (nth 1 reftex-cite-punctuation)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4754 last)))))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4755
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4756 (defun reftex-format-citation (entry format)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4757 ;; 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
4758
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4759 (unless (stringp format) (setq format "\\cite{%l}"))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4760
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4761 (if (and reftex-comment-citations
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4762 (string-match "%l" reftex-cite-comment-format))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4763 (error "reftex-cite-comment-format contains illegal %%l"))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4764
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4765 (while (string-match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4766 "\\(\\`\\|[^%]\\)\\(\\(%\\([0-9]*\\)\\([a-zA-Z]\\)\\)[.,;: ]*\\)"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4767 format)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4768 (let ((n (string-to-int (match-string 4 format)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4769 (l (string-to-char (match-string 5 format)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4770 rpl b e)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4771 (save-match-data
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4772 (setq rpl
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4773 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4774 ((= l ?l) (concat
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4775 (reftex-get-bib-field "&key" entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4776 (if reftex-comment-citations
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4777 reftex-cite-comment-format
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4778 "")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4779 ((= l ?a) (reftex-format-names
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4780 (reftex-get-bib-names "author" entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4781 (or n 2)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4782 ((= l ?A) (car (reftex-get-bib-names "author" entry)))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4783 ((= l ?b) (reftex-get-bib-field "booktitle" entry "in: %s"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4784 ((= l ?B) (reftex-abbreviate-title
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4785 (reftex-get-bib-field "booktitle" entry "in: %s")))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4786 ((= l ?c) (reftex-get-bib-field "chapter" entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4787 ((= l ?d) (reftex-get-bib-field "edition" entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4788 ((= l ?e) (reftex-format-names
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4789 (reftex-get-bib-names "editor" entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4790 (or n 2)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4791 ((= l ?E) (car (reftex-get-bib-names "editor" entry)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4792 ((= l ?h) (reftex-get-bib-field "howpublished" entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4793 ((= l ?i) (reftex-get-bib-field "institution" entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4794 ((= l ?j) (reftex-get-bib-field "journal" entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4795 ((= l ?k) (reftex-get-bib-field "key" entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4796 ((= l ?m) (reftex-get-bib-field "month" entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4797 ((= l ?n) (reftex-get-bib-field "number" entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4798 ((= l ?o) (reftex-get-bib-field "organization" entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4799 ((= l ?p) (reftex-get-bib-field "pages" entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4800 ((= l ?P) (car (split-string
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4801 (reftex-get-bib-field "pages" entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4802 "[- .]+")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4803 ((= l ?s) (reftex-get-bib-field "school" entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4804 ((= l ?u) (reftex-get-bib-field "publisher" entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4805 ((= l ?r) (reftex-get-bib-field "address" entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4806 ((= l ?t) (reftex-get-bib-field "title" entry))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4807 ((= l ?T) (reftex-abbreviate-title
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4808 (reftex-get-bib-field "title" entry)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4809 ((= l ?v) (reftex-get-bib-field "volume" entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4810 ((= l ?y) (reftex-get-bib-field "year" entry)))))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4811
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4812 (if (string= rpl "")
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4813 (setq b (match-beginning 2) e (match-end 2))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4814 (setq b (match-beginning 3) e (match-end 3)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4815 (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
4816 (while (string-match "%%" format)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4817 (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
4818 (while (string-match "[ ,.;:]*%<" format)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4819 (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
4820 format)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4821
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4822 (defun reftex-bibtex-selection-callback (data ignore no-revisit)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4823 ;; 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
4824 ;; order to display context. This function is relatively slow and not
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4825 ;; recommended for follow mode. It works OK for individual lookups.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4826 (let ((win (selected-window))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4827 (key (reftex-get-bib-field "&key" data))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4828 bibfile-list item tmp)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4830 (catch 'exit
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4831 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4832 (set-buffer reftex-call-back-to-this-buffer)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4833 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4834 ((assq 'bib (symbol-value reftex-docstruct-symbol))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4835 (setq bibfile-list (reftex-get-bibfile-list)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4836 ((setq tmp (assq 'thebib (symbol-value reftex-docstruct-symbol)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4837 (setq bibfile-list (list (cdr tmp))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4838 item t))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4839 (reftex-default-bibliography
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4840 (setq bibfile-list reftex-default-bibliography))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4841 (t (ding) (throw 'exit))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4842
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4843 (when no-revisit
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4844 (setq bibfile-list (reftex-visited-files bibfile-list)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4845
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4846 (condition-case nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4847 (reftex-pop-to-bibtex-entry
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4848 key bibfile-list (not reftex-keep-temporary-buffers) t item)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4849 (error (ding))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4850
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4851 (select-window win)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4852
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4853 ;;; =========================================================================
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4854 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4855 ;;; Here is the routine used for selection
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4856
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4857 ;; Marker for return point from recursive edit
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4858 (defvar reftex-recursive-edit-marker (make-marker))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4859
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4860 (defvar reftex-last-data nil)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4861 (defvar reftex-last-line nil)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4862
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4863 (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
4864 ;; Check if we are already in a recursive edit. Abort with helpful
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4865 ;; message if so.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4866 (if (marker-position reftex-recursive-edit-marker)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4867 (error
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4868 (substitute-command-keys
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4869 "In unfinished selection process. Finish, or abort with \\[abort-recursive-edit]."))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4870
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4871 (defun reftex-select-item (prompt help-string keymap
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4872 &optional offset
21115
fea2f6a2818d 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21114
diff changeset
4873 call-back cb-flag)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4874 ;; Select an item, using PROMPT. The function returns a key indicating
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4875 ;; an exit status, along with a data structure indicating which item was
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4876 ;; selected.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4877 ;; HELP-STRING contains help. KEYMAP is a keymap with the available
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4878 ;; selection commands.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4879 ;; OFFSET can be a label list item which will be selected at start.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4880 ;; When it is t, point will start out at the beginning of the buffer.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4881 ;; Any other value will cause restart where last selection left off.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4882 ;; When CALL-BACK is given, it is a function which is called with the index
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4883 ;; of the element.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4884 ;; CB-FLAG is the initial value of that flag.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4885
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
4886 (let* (ev data last-data (selection-buffer (current-buffer)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4887
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4888 (setq ev
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4889 (catch 'myexit
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4890 (save-window-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4891 (setq truncate-lines t)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4892
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4893 ;; Find a good starting point
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
4894 (reftex-find-start-point
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
4895 (point-min) offset reftex-last-data reftex-last-line)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4896 (beginning-of-line 1)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4897 (set (make-local-variable 'reftex-last-follow-point) (point))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4898
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4899 (unwind-protect
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4900 (progn
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4901 (use-local-map keymap)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4902 (add-hook 'pre-command-hook 'reftex-select-pre-command-hook nil t)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4903 (add-hook 'post-command-hook 'reftex-select-post-command-hook nil t)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4904 (princ prompt)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4905 (set-marker reftex-recursive-edit-marker (point))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4906 ;; XEmacs does not run post-command-hook here
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
4907 (and (featurep 'xemacs) (run-hooks 'post-command-hook))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4908 (recursive-edit))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4909
21075
0c95fb73e090 1998-03-06 Carsten Dominik <cd@delysid.gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21002
diff changeset
4910 (set-marker reftex-recursive-edit-marker nil)
0c95fb73e090 1998-03-06 Carsten Dominik <cd@delysid.gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21002
diff changeset
4911 (save-excursion
0c95fb73e090 1998-03-06 Carsten Dominik <cd@delysid.gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21002
diff changeset
4912 (set-buffer selection-buffer)
0c95fb73e090 1998-03-06 Carsten Dominik <cd@delysid.gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21002
diff changeset
4913 (use-local-map nil)
0c95fb73e090 1998-03-06 Carsten Dominik <cd@delysid.gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21002
diff changeset
4914 (remove-hook 'pre-command-hook 'reftex-select-pre-command-hook t)
0c95fb73e090 1998-03-06 Carsten Dominik <cd@delysid.gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21002
diff changeset
4915 (remove-hook 'post-command-hook
0c95fb73e090 1998-03-06 Carsten Dominik <cd@delysid.gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21002
diff changeset
4916 'reftex-select-post-command-hook t))))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4917
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4918 (set (make-local-variable 'reftex-last-line)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4919 (+ (count-lines (point-min) (point)) (if (bolp) 1 0)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4920 (set (make-local-variable 'reftex-last-data) last-data)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4921 (reftex-kill-buffer "*RefTeX Help*")
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
4922 (setq reftex-callback-fwd (not reftex-callback-fwd)) ;; ;-)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4923 (message "")
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4924 (list ev data last-data)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4925
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4926 ;; The following variables are all bound dynamically in `reftex-select-item'.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4927 ;; The defvars are here only to silence the byte compiler.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4928
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4929 (defvar found-list)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4930 (defvar cb-flag)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4931 (defvar data)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4932 (defvar prompt)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4933 (defvar last-data)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4934 (defvar call-back)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4935 (defvar help-string)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4936 (defvar varioref)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4937
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4938 ;; The selection commands
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4939
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4940 (defun reftex-select-pre-command-hook ()
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4941 (reftex-unhighlight 1)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4942 (reftex-unhighlight 0))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4943
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4944 (defun reftex-select-post-command-hook ()
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4945 (let (b e)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4946 (setq data (get-text-property (point) ':data))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4947 (setq last-data (or data last-data))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4948
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4949 (when (and data cb-flag
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4950 (not (equal reftex-last-follow-point (point))))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4951 (setq reftex-last-follow-point (point))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
4952 (funcall call-back data reftex-callback-fwd
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4953 (not reftex-revisit-to-follow)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4954 (if data
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4955 (setq b (or (previous-single-property-change
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4956 (1+ (point)) ':data)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4957 (point-min))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4958 e (or (next-single-property-change
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4959 (point) ':data)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4960 (point-max)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4961 (setq b (point) e (point)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4962 (and (memq reftex-highlight-selection '(cursor both))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4963 (reftex-highlight 1 b e))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4964 (if (or (not (pos-visible-in-window-p b))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4965 (not (pos-visible-in-window-p e)))
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
4966 (recenter '(4)))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4967 (unless (current-message)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4968 (princ prompt))))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4969
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4970 (defun reftex-select-next (&optional arg)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4971 "Move to next selectable item."
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4972 (interactive "p")
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
4973 (setq reftex-callback-fwd t)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4974 (or (eobp) (forward-char 1))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4975 (re-search-forward "^[^. \t\n\r]" nil t arg)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4976 (beginning-of-line 1))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4977 (defun reftex-select-previous (&optional arg)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4978 "Move to previous selectable item."
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4979 (interactive "p")
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
4980 (setq reftex-callback-fwd nil)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4981 (re-search-backward "^[^. \t\n\r]" nil t arg))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4982 (defun reftex-select-next-heading (&optional arg)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4983 "Move to next table of contentes line."
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4984 (interactive "p")
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4985 (end-of-line)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4986 (re-search-forward "^ " nil t arg)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4987 (beginning-of-line))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4988 (defun reftex-select-previous-heading (&optional arg)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4989 "Move to previous table of contentes line."
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4990 (interactive "p")
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4991 (re-search-backward "^ " nil t arg))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4992 (defun reftex-select-quit ()
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4993 "Abort selection process."
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4994 (interactive)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4995 (throw 'myexit nil))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4996 (defun reftex-select-keyboard-quit ()
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4997 "Abort selection process."
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4998 (interactive)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4999 (throw 'exit t))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5000 (defun reftex-select-jump-to-previous ()
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5001 "Jump back to where previous selection process left off."
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5002 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5003 (let (pos)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5004 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5005 ((and (local-variable-p 'reftex-last-data (current-buffer))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5006 reftex-last-data
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5007 (setq pos (text-property-any (point-min) (point-max)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5008 ':data reftex-last-data)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5009 (goto-char pos))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5010 ((and (local-variable-p 'reftex-last-line (current-buffer))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5011 (integerp reftex-last-line))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5012 (goto-line reftex-last-line))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5013 (t (ding)))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5014 (defun reftex-select-toggle-follow ()
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5015 "Toggle follow mode: Other window follows with full context."
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5016 (interactive)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5017 (setq reftex-last-follow-point -1)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5018 (setq cb-flag (not cb-flag)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5019 (defun reftex-select-toggle-varioref ()
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5020 "Toggle the macro used for referencing the label between \\ref and \\vref."
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5021 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5022 (if (string= varioref "\\ref")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5023 (setq varioref "\\vref")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5024 (setq varioref "\\ref"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5025 (force-mode-line-update))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5026 (defun reftex-select-show-insertion-point ()
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5027 "Show the point from where selection was started in another window."
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5028 (interactive)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5029 (let ((this-window (selected-window)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5030 (unwind-protect
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5031 (progn
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5032 (switch-to-buffer-other-window
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5033 (marker-buffer reftex-select-return-marker))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5034 (goto-char (marker-position reftex-select-return-marker))
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5035 (recenter '(4)))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5036 (select-window this-window))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5037 (defun reftex-select-callback ()
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5038 "Show full context in another window."
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5039 (interactive)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5040 (if data (funcall call-back data reftex-callback-fwd nil) (ding)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5041 (defun reftex-select-accept ()
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5042 "Accept the currently selected item."
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5043 (interactive)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5044 (throw 'myexit 'return))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5045 (defun reftex-select-mouse-accept (ev)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5046 "Accept the item at the mouse click."
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5047 (interactive "e")
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5048 (mouse-set-point ev)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5049 (setq data (get-text-property (point) ':data))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5050 (setq last-data (or data last-data))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5051 (throw 'myexit 'return))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5052 (defun reftex-select-read-label ()
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5053 "Use minibuffer to read a label to reference, with completion."
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5054 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5055 (let ((label (completing-read
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5056 "Label: " (symbol-value reftex-docstruct-symbol)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5057 nil nil reftex-prefix)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5058 (unless (or (equal label "") (equal label reftex-prefix))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5059 (throw 'myexit label))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5060 (defun reftex-select-read-cite ()
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5061 "Use minibuffer to read a citation key with completion."
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5062 (interactive)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5063 (let* ((key (completing-read "Citation key: " found-list))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5064 (entry (assoc key found-list)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5065 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5066 ((or (null key) (equal key "")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5067 (entry
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5068 (setq data entry)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5069 (setq last-data data)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5070 (throw 'myexit 'return))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5071 (t (throw 'myexit key)))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5072 (defun reftex-select-help ()
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5073 "Display a summary of the special key bindings."
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5074 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5075 (with-output-to-temp-buffer "*RefTeX Help*"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5076 (princ help-string))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5077 (reftex-enlarge-to-fit "*RefTeX Help*" t))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5078
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5079 ;;; =========================================================================
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5080 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5081 ;;; View cross references
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5082
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5083 (defun reftex-view-crossref (&optional arg how)
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
5084 "View cross reference of \\ref or \\cite macro at point.
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
5085 If the macro at point is a \\ref, show the corresponding label definition.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5086 If it is a \\cite, show the BibTeX database entry or the \\bibitem.
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5087 To cope with the plethora of variations in packages, this
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5088 function assumes any macro either starting with or ending in `ref' or
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5089 `cite' to contain cross references.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5090 When the LaTeX package `xr' is being used, this command will also view
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5091 crossreferences in external documents. However, this works correctly only
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5092 when the \\externaldocument macros are used with the optional label prefix
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5093 argument.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5094 With one or two C-u prefixes, enforce rescanning of the document.
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5095 With argument 2, select the window showing the cross reference.
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5096 When HOW is 'echo, call the corresponding echo function.
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5097 When HOW is 'tmp-window, make the pop-up window as small as possible and
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5098 arrange for its removal before the next command."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5099
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5100 (interactive "P")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5101
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5102 ;; See where we are.
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5103 (let* ((macro (car (reftex-what-macro 1)))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5104 (key (reftex-this-word "^{}%\n\r,")))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5105
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5106 (setq reftex-call-back-to-this-buffer (current-buffer))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5107
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5108 (if (and macro
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5109 (string-match "\\`\\\\cite\\|\\`\\\\ref\\|cite\\'\\|ref\\'"
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5110 macro))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5111 (and (setq macro (match-string 0 macro))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5112 (string-match "\\`\\\\" macro)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5113 (setq macro (substring macro 1)))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5114 (setq macro nil))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5115
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5116 (if (or (null macro) (reftex-in-comment))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5117 (error "No cross reference to display"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5118
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5119 (if (eq how 'tmp-window)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5120 ;; Remember the window configuration
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5121 (put 'reftex-auto-view-crossref 'last-window-conf
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5122 (current-window-configuration)))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5123 (cond
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5124 ((string= macro "cite")
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5125 (reftex-view-cr-cite arg key how))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5126 ((string= macro "ref")
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5127 (reftex-view-cr-ref arg key how))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5128 (t
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5129 (error "Cannot display crossref\n")))))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5130
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5131 (defun reftex-view-cr-cite (arg key how)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5132 ;; View crossreference of a ref cite. HOW can have the values
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5133 ;; nil: Show in another window.
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5134 ;; echo: Show one-line info in echo area.
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5135 ;; tmp-window: Show in small window and arrange for window to disappear.
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5136
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5137 ;; Ensure access to scanning info
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5138 (reftex-access-scan-info (or arg current-prefix-arg))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5139
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5140 (let (files size item (pos (point)) (win (selected-window)) pop-win)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5141 ;; Find the citation mode and the file list
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5142 (cond
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5143 ((assq 'bib (symbol-value reftex-docstruct-symbol))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5144 (setq item nil
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5145 files (reftex-get-bibfile-list)))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5146 ((assq 'thebib (symbol-value reftex-docstruct-symbol))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5147 (setq item t
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5148 files (list (cdr (assq 'thebib
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5149 (symbol-value reftex-docstruct-symbol))))))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5150 (reftex-default-bibliography
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5151 (setq item nil
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5152 files reftex-default-bibliography))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5153 (how) ;; don't throw for special display
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5154 (t (error "Cannot display crossref")))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5155
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5156 (if (eq how 'echo)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5157 ;; Display in Echo area
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5158 (reftex-echo-cite key files item)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5159 ;; Display in a window
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5160 (if (not (eq how 'tmp-window))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5161 ;; Normal display
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5162 (reftex-pop-to-bibtex-entry key files nil t item)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5163 ;; A temporary window
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5164 (condition-case nil
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5165 (reftex-pop-to-bibtex-entry key files nil t item)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5166 (error (goto-char pos)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5167 (message "cite: no such citation key %s" key)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5168 (error "")))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5169 ;; Resize the window
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5170 (setq size (max 1 (count-lines (point)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5171 (reftex-end-of-bib-entry item))))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5172 (let ((window-min-height 2))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5173 (shrink-window (1- (- (window-height) size)))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5174 (recenter 0))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5175 ;; Arrange restoration
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5176 (add-hook 'pre-command-hook 'reftex-restore-window-conf))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5177
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5178 ;; Normal display in other window
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5179 (add-hook 'pre-command-hook 'reftex-highlight-shall-die)
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5180 (setq pop-win (selected-window))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5181 (select-window win)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5182 (goto-char pos)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5183 (when (equal arg 2)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5184 (select-window pop-win)))))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5185
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5186 (defun reftex-view-cr-ref (arg label how)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5187 ;; View crossreference of a ref macro. HOW can have the values
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5188 ;; nil: Show in another window.
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5189 ;; echo: Show one-line info in echo area.
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5190 ;; tmp-window: Show in small window and arrange for window to disappear.
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5191
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5192 ;; Ensure access to scanning info
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5193 (reftex-access-scan-info (or arg current-prefix-arg))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5194
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5195 (let* ((xr-data (assoc 'xr (symbol-value reftex-docstruct-symbol)))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5196 (xr-re (nth 2 xr-data))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5197 (entry (assoc label (symbol-value reftex-docstruct-symbol)))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5198 (win (selected-window)) pop-win (pos (point)))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5199
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5200 (if (and (not entry) (stringp label) xr-re (string-match xr-re label))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5201 ;; Label is defined in external document
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5202 (save-excursion
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5203 (save-match-data
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5204 (set-buffer
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5205 (or (reftex-get-file-buffer-force
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5206 (cdr (assoc (match-string 1 label) (nth 1
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5207 xr-data))))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5208 (error "Problem with external label %s" label))))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5209 (setq label (substring label (match-end 1)))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5210 (reftex-access-scan-info)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5211 (setq entry
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5212 (assoc label (symbol-value reftex-docstruct-symbol)))))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5213 (if (eq how 'echo)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5214 ;; Dsiplay in echo area
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5215 (reftex-echo-ref label entry (symbol-value reftex-docstruct-symbol))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5216 (let ((window-conf (current-window-configuration)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5217 (condition-case nil
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5218 (reftex-show-label-location entry t nil t t)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5219 (error (set-window-configuration window-conf)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5220 (message "ref: Label %s not found" label)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5221 (error "ref: Label %s not found" label)))) ;; 2nd is line OK
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5222 (add-hook 'pre-command-hook 'reftex-highlight-shall-die)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5223
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5224 (when (eq how 'tmp-window)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5225 ;; Resize window and arrange restauration
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5226 (shrink-window (1- (- (window-height) 9)))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5227 (recenter '(4))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5228 (add-hook 'pre-command-hook 'reftex-restore-window-conf))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5229 (setq pop-win (selected-window))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5230 (select-window win)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5231 (goto-char pos)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5232 (when (equal arg 2)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5233 (select-window pop-win)))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5234
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5235 (defun reftex-mouse-view-crossref (ev)
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
5236 "View cross reference of \\ref or \\cite macro where you click.
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
5237 If the macro at point is a \\ref, show the corresponding label definition.
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
5238 If it is a \\cite, show the BibTeX database entry.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5239 If there is no such macro at point, search forward to find one.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5240 With argument, actually select the window showing the cross reference."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5241 (interactive "e")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5242 (mouse-set-point ev)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5243 (reftex-view-crossref current-prefix-arg))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5244
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5245 (defvar reftex-auto-view-crossref-timer nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5246 "The timer used for auto-view-crossref.")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5247
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5248 (defun reftex-view-crossref-when-idle ()
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5249 ;; Display info about crossref at point in echo area or a window.
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5250 ;; This function was desigend to work with an idle timer.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5251 ;; We try to get out of here as quickly as possible if the call is useless.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5252 (and reftex-mode
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5253 ;; Make sure message area is free if we need it.
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5254 (or (eq reftex-auto-view-crossref 'window) (not (current-message)))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5255 ;; Make sure we are not already displaying this one
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5256 (not (memq last-command '(reftex-view-crossref
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5257 reftex-mouse-view-crossref)))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5258 ;; Quick precheck if this might be a relevant spot
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5259 ;; FIXME: Can fail with backslash in comment
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5260 (save-excursion
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5261 (search-backward "\\" nil t)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5262 (looking-at "\\\\[a-zA-Z]*\\(cite\\|ref\\)"))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5263
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5264 (condition-case nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5265 (let ((current-prefix-arg nil))
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5266 (cond
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5267 ((eq reftex-auto-view-crossref t)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5268 (reftex-view-crossref -1 'echo))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5269 ((eq reftex-auto-view-crossref 'window)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5270 (reftex-view-crossref -1 'tmp-window))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5271 (t nil)))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5272 (error nil))))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5273
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5274 (defun reftex-restore-window-conf ()
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5275 (set-window-configuration (get 'reftex-auto-view-crossref 'last-window-conf))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5276 (put 'reftex-auto-view-crossref 'last-window-conf nil)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5277 (remove-hook 'pre-command-hook 'reftex-restore-window-conf))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5278
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5279 (defun reftex-echo-ref (label entry docstruct)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5280 ;; Display crossref info in echo area.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5281 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5282 ((null docstruct)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5283 (message (substitute-command-keys (format reftex-no-info-message "ref"))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5284 ((null entry)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5285 (message "ref: unknown label: %s" label))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5286 (t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5287 (when (stringp (nth 2 entry))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5288 (message "ref(%s): %s" (nth 1 entry) (nth 2 entry)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5289 (let ((buf (get-buffer " *Echo Area*")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5290 (when buf
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5291 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5292 (set-buffer buf)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5293 (run-hooks 'reftex-display-copied-context-hook)))))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5294
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5295 (defun reftex-echo-cite (key files item)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5296 ;; Display citation info in echo area.
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5297 (let* ((cache (assq 'bibview-cache (symbol-value reftex-docstruct-symbol)))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5298 (cache-entry (assoc key (cdr cache)))
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5299 entry string buf (all-files files))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5300
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5301 (if (and reftex-cache-cite-echo cache-entry)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5302 ;; We can just use the cache
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5303 (setq string (cdr cache-entry))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5304
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5305 ;; Need to look in the database
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5306 (unless reftex-revisit-to-echo
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5307 (setq files (reftex-visited-files files)))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5308
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5309 (setq entry
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5310 (condition-case nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5311 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5312 (reftex-pop-to-bibtex-entry key files nil nil item t))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5313 (error
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5314 (if (and files (= (length all-files) (length files)))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5315 (message "cite: no such database entry: %s" key)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5316 (message (substitute-command-keys
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5317 (format reftex-no-info-message "cite"))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5318 nil)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5319 (when entry
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5320 (if item
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5321 (setq string (reftex-nicify-text entry))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5322 (setq string (reftex-make-cite-echo-string
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5323 (reftex-parse-bibtex-entry entry)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5324 reftex-docstruct-symbol)))))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5325 (unless (or (null string) (equal string ""))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5326 (message "cite: %s" string))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5327 (when (setq buf (get-buffer " *Echo Area*"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5328 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5329 (set-buffer buf)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5330 (run-hooks 'reftex-display-copied-context-hook)))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5331
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5332 (defun reftex-make-cite-echo-string (entry docstruct-symbol)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5333 ;; Format a bibtex entry for the echo area and cache the result.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5334 (let* ((key (reftex-get-bib-field "&key" entry))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5335 (string
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5336 (let* ((reftex-cite-punctuation '(" " " & " " etal.")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5337 (reftex-format-citation entry reftex-cite-view-format)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5338 (cache (assq 'bibview-cache (symbol-value docstruct-symbol)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5339 (cache-entry (assoc key (cdr cache))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5340 (unless cache
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5341 ;; This docstruct has no cache - make one.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5342 (set docstruct-symbol (cons (cons 'bibview-cache nil)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5343 (symbol-value docstruct-symbol))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5344 (when reftex-cache-cite-echo
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5345 (setq key (copy-sequence key))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5346 (set-text-properties 0 (length key) nil key)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5347 (set-text-properties 0 (length string) nil string)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5348 (if cache-entry
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5349 (unless (string= (cdr cache-entry) string)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5350 (setcdr cache-entry string)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5351 (put reftex-docstruct-symbol 'modified t))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5352 (push (cons key string) (cdr cache))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5353 (put reftex-docstruct-symbol 'modified t)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5354 string))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5355
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5356 (defvar reftex-use-itimer-in-xemacs nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5357 "*Non-nil means use the idle timers in XEmacs for crossref display.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5358 Currently, idle timer restart is broken and we use the post-command-hook.")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5359
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5360 (defun reftex-toggle-auto-view-crossref ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5361 "Toggle the automatic display of crossref information in the echo area.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5362 When active, leaving point idle in the argument of a \\ref or \\cite macro
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5363 will display info in the echo area."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5364 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5365 (if reftex-auto-view-crossref-timer
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5366 (progn
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5367 (if (featurep 'xemacs)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5368 (if reftex-use-itimer-in-xemacs
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5369 (delete-itimer reftex-auto-view-crossref-timer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5370 (remove-hook 'post-command-hook 'reftex-start-itimer-once))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5371 (cancel-timer reftex-auto-view-crossref-timer))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5372 (setq reftex-auto-view-crossref-timer nil)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5373 (message "Automatic display of crossref information was turned off"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5374 (setq reftex-auto-view-crossref-timer
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5375 (if (featurep 'xemacs)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5376 (if reftex-use-itimer-in-xemacs
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5377 (start-itimer "RefTeX Idle Timer"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5378 'reftex-view-crossref-when-idle
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5379 reftex-idle-time reftex-idle-time t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5380 (add-hook 'post-command-hook 'reftex-start-itimer-once)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5381 t)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5382 (run-with-idle-timer
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5383 reftex-idle-time t 'reftex-view-crossref-when-idle)))
23344
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5384 (unless reftex-auto-view-crossref
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5385 (setq reftex-auto-view-crossref t))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5386 (message "Automatic display of crossref information was turned on")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5387
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5388 (defun reftex-start-itimer-once ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5389 (and reftex-mode
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5390 (not (itimer-live-p reftex-auto-view-crossref-timer))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5391 (setq reftex-auto-view-crossref-timer
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5392 (start-itimer "RefTeX Idle Timer"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5393 'reftex-view-crossref-when-idle
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5394 reftex-idle-time nil t))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5395
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5396 ;;; =========================================================================
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5397 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5398 ;;; Functions that check out the surroundings
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5399
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5400 (defun reftex-what-macro (which &optional bound)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5401 ;; 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
5402 ;; The return value is either ("\\macro" . (point)) or a list of them.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5403
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5404 ;; If WHICH is nil, immediately return nil.
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5405 ;; If WHICH is 1, return innermost enclosing macro.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5406 ;; If WHICH is t, return list of all macros enclosing point.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5407 ;; If WHICH is a list of macros, look only for those macros and return the
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5408 ;; name of the first macro in this list found to enclose point.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5409 ;; 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
5410 ;; searches to this point. If it is nil, limit to nearest \section -
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5411 ;; like statement.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5412
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5413 ;; 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
5414 ;; 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
5415 ;; 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
5416 ;; considered an argument of macro \macro.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5417
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5418 (unless reftex-section-regexp (reftex-compile-variables))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5419 (catch 'exit
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5420 (if (null which) (throw 'exit nil))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5421 (let ((bound (or bound (save-excursion (re-search-backward
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5422 reftex-section-regexp nil 1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5423 (point))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5424 pos cmd-list cmd cnt cnt-opt entry)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5425 (save-restriction
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5426 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5427 (narrow-to-region (max 1 bound) (point-max))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5428 ;; move back out of the current parenthesis
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5429 (while (condition-case nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5430 (progn (up-list -1) t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5431 (error nil))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5432 (setq cnt 1 cnt-opt 0)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5433 ;; move back over any touching sexps
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5434 (while (and (reftex-move-to-previous-arg bound)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5435 (condition-case nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5436 (progn (backward-sexp) t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5437 (error nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5438 (if (eq (following-char) ?\[) (incf cnt-opt))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5439 (incf cnt))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5440 (setq pos (point))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5441 (when (and (or (= (following-char) ?\[)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5442 (= (following-char) ?\{))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5443 (re-search-backward "\\\\[*a-zA-Z]+\\=" nil t))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5444 (setq cmd (reftex-match-string 0))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5445 (when (looking-at "\\\\begin{[^}]*}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5446 (setq cmd (reftex-match-string 0)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5447 cnt (1- cnt)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5448 ;; This does ignore optional arguments. Very hard to fix.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5449 (when (setq entry (assoc cmd reftex-env-or-mac-alist))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5450 (if (> cnt (or (nth 4 entry) 100))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5451 (setq cmd nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5452 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5453 ((null cmd))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5454 ((eq t which)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5455 (push (cons cmd (point)) cmd-list))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5456 ((or (eq 1 which) (member cmd which))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5457 (throw 'exit (cons cmd (point))))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5458 (goto-char pos)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5459 (nreverse cmd-list)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5460
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5461 (defun reftex-what-environment (which &optional bound)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5462 ;; 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
5463 ;; The return value is (e.g.) either ("equation" . (point)) or a list of
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5464 ;; them.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5465
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5466 ;; If WHICH is nil, immediately return nil.
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5467 ;; If WHICH is 1, return innermost enclosing environment.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5468 ;; If WHICH is t, return list of all environments enclosing point.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5469 ;; If WHICH is a list of environments, look only for those environments and
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5470 ;; return the name of the first environment in this list found to enclose
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5471 ;; point.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5472
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5473 ;; 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
5474 ;; this point. If it is nil, limit to nearest \section - like statement.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5475
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5476 (unless reftex-section-regexp (reftex-compile-variables))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5477 (catch 'exit
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5478 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5479 (if (null which) (throw 'exit nil))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5480 (let ((bound (or bound (save-excursion (re-search-backward
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5481 reftex-section-regexp nil 1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5482 (point))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5483 env-list end-list env)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5484 (while (re-search-backward "\\\\\\(begin\\|end\\){\\([^}]+\\)}"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5485 bound t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5486 (setq env (buffer-substring-no-properties
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5487 (match-beginning 2) (match-end 2)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5488 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5489 ((string= (match-string 1) "end")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5490 (add-to-list 'end-list env))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5491 ((member env end-list)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5492 (setq end-list (delete env end-list)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5493 ((eq t which)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5494 (push (cons env (point)) env-list))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5495 ((or (eq 1 which) (member env which))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5496 (throw 'exit (cons env (point))))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5497 (nreverse env-list)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5498
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5499 ;;; =========================================================================
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5500 ;;;
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5501 ;;; Finding files
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5502
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5503 (defun reftex-locate-file (file type master-dir &optional die)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5504 "Find FILE of type TYPE in MASTER-DIR or on the path associcted with TYPE.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5505 If the file does not have any of the legal extensions for TYPE,
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5506 try first the default extension and only then the naked file name.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5507 When DIE is non-nil, throw an error if file not found."
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5508 (let* ((rec-values (if reftex-search-unrecursed-path-first '(nil t) '(t)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5509 (extensions (cdr (assoc type reftex-file-extensions)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5510 (def-ext (car extensions))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5511 (ext-re (concat "\\("
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5512 (mapconcat 'regexp-quote extensions "\\|")
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5513 "\\)\\'"))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5514 (files (if (string-match ext-re file)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5515 (cons file nil)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5516 (cons (concat file def-ext) file)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5517 path old-path file1)
23344
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5518 (cond
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5519 ((file-name-absolute-p file)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5520 (setq file1
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5521 (or
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5522 (and (car files) (file-regular-p (car files)) (car files))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5523 (and (cdr files) (file-regular-p (cdr files)) (cdr files)))))
23344
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5524 ((and reftex-use-external-file-finders
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5525 (assoc type reftex-external-file-finders))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5526 (setq file1 (reftex-find-file-externally file type master-dir)))
23344
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5527 (t
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5528 (while (and (null file1) rec-values)
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5529 (setq path (reftex-access-search-path
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5530 type (pop rec-values) master-dir file))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5531 (if (or (null old-path)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5532 (not (eq old-path path)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5533 (setq old-path path
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5534 path (cons master-dir path)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5535 file1 (or (and (car files)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5536 (reftex-find-file-on-path
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5537 (car files) path master-dir))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5538 (and (cdr files)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5539 (reftex-find-file-on-path
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5540 (cdr files) path master-dir))))))))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5541 (cond (file1 file1)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5542 (die (error "No such file: %s" file) nil)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5543 (t (message "No such file: %s (ignored)" file) nil))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5544
23344
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5545 (defun reftex-find-file-externally (file type &optional master-dir)
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5546 ;; Use external program to find FILE.
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5547 ;; The program is taken from `reftex-external-file-finders'.
23344
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5548 ;; Interprete relative path definitions starting from MASTER-DIR.
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5549 (let ((default-directory (or master-dir default-directory))
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5550 (prg (cdr (assoc type reftex-external-file-finders)))
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5551 out)
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5552 (if (string-match "%f" prg)
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5553 (setq prg (replace-match file t t prg)))
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5554 (setq out (apply 'reftex-process-string (split-string prg)))
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5555 (if (string-match "[ \t\n]+\\'" out)
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5556 (setq out (replace-match "" nil nil out)))
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5557 (cond ((equal out "") nil)
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5558 ((file-regular-p out) out)
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5559 (t nil))))
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5560
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5561 (defun reftex-process-string (program &rest args)
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5562 "Execute PROGRAM with arguments ARGS and return its STDOUT as a string."
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5563 (with-output-to-string
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5564 (with-current-buffer standard-output
23344
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5565 (apply 'call-process program nil '(t nil) nil args))))
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5566
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5567 (defun reftex-access-search-path (type &optional recurse master-dir file)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5568 ;; Access path from environment variables. TYPE is either "tex" or "bib".
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5569 ;; When RECURSE is t, expand path elements ending in `//' recursively.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5570 ;; Relative path elements are left as they are. However, relative recursive
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5571 ;; elements are expanded with MASTER-DIR as default directory.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5572 ;; The expanded path is cached for the next search.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5573 ;; FILE is just for the progress message.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5574 ;; Returns the derived path.
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5575 (let* ((pathvar (intern (concat "reftex-" type "-path"))))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5576 (when (null (get pathvar 'status))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5577 ;; Get basic path
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5578 (set pathvar
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5579 (reftex-uniq
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5580 (reftex-parse-colon-path
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5581 (mapconcat
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5582 (lambda(x)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5583 (if (string-match "^!" x)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5584 (apply 'reftex-process-string
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5585 (split-string (substring x 1)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5586 (or (getenv x) x)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5587 ;; For consistency, the next line should look like this:
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5588 ;; (cdr (assoc type reftex-path-environment))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5589 ;; However, historically we have separate options for the
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5590 ;; environment variables, so we have to do this:
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5591 (symbol-value (intern (concat "reftex-" type
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5592 "path-environment-variables")))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5593 path-separator))))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5594 (put pathvar 'status 'split)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5595 ;; Check if we have recursive elements
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5596 (let ((path (symbol-value pathvar)) dir rec)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5597 (while (setq dir (pop path))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5598 (when (string= (substring dir -2) "//")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5599 (if (file-name-absolute-p dir)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5600 (setq rec (or rec 'absolute))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5601 (setq rec 'relative))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5602 (put pathvar 'rec-type rec)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5603
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5604 (if recurse
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5605 ;; Return the recursive expansion of the path
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5606 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5607 ((not (get pathvar 'rec-type))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5608 ;; Path does not contain recursive elements - use simple path
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5609 (symbol-value pathvar))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5610 ((or (not (get pathvar 'recursive-path))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5611 (and (eq (get pathvar 'rec-type) 'relative)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5612 (not (equal master-dir (get pathvar 'master-dir)))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5613 ;; Either: We don't have a recursive expansion yet.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5614 ;; or: Relative recursive path elements need to be expanded
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5615 ;; relative to new default directory
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5616 (message "Expanding search path to find %s file: %s ..." type file)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5617 (put pathvar 'recursive-path
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5618 (reftex-expand-path (symbol-value pathvar) master-dir))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5619 (put pathvar 'master-dir master-dir)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5620 (get pathvar 'recursive-path))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5621 (t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5622 ;; Recursive path computed earlier is still OK.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5623 (get pathvar 'recursive-path)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5624 ;; The simple path was requested
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5625 (symbol-value pathvar))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5626
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5627 (defun reftex-find-file-on-path (file path &optional def-dir)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5628 ;; Find FILE along the directory list PATH.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5629 ;; DEF-DIR is the default directory for expanding relative path elements.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5630 (catch 'exit
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5631 (when (file-name-absolute-p file)
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5632 (if (file-regular-p file)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5633 (throw 'exit file)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5634 (throw 'exit nil)))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5635 (let* ((thepath path) file1 dir)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5636 (while (setq dir (pop thepath))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5637 (when (string= (substring dir -2) "//")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5638 (setq dir (substring dir 0 -1)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5639 (setq file1 (expand-file-name file (expand-file-name dir def-dir)))
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5640 (if (file-regular-p file1)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5641 (throw 'exit file1)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5642 ;; No such file
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5643 nil)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5644
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5645 (defun reftex-parse-colon-path (path)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5646 ;; Like parse-colon-parse, but // or /~ are left alone.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5647 ;; Trailing ! or !! will be converted into `//' (emTeX convention)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5648 (mapcar
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5649 (lambda (dir)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5650 (if (string-match "\\(//+\\|/*!+\\)\\'" dir)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5651 (setq dir (replace-match "//" t t dir)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5652 (file-name-as-directory dir))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5653 (delete "" (split-string path (concat path-separator "+")))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5654
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5655 (defun reftex-expand-path (path &optional default-dir)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5656 ;; Expand parts of path ending in `//' recursively into directory list.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5657 ;; Relative recursive path elements are expanded relative to DEFAULT-DIR.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5658 (let (path1 dir recursive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5659 (while (setq dir (pop path))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5660 (if (setq recursive (string= (substring dir -2) "//"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5661 (setq dir (substring dir 0 -1)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5662 (if (and recursive
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5663 (not (file-name-absolute-p dir)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5664 (setq dir (expand-file-name dir default-dir)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5665 (if recursive
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5666 ;; Expand recursively
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5667 (setq path1 (append (reftex-recursive-directory-list dir) path1))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5668 ;; Keep unchanged
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5669 (push dir path1)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5670 (nreverse path1)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5671
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5672 (defun reftex-recursive-directory-list (dir)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5673 ;; Return a list of all directories below DIR, including DIR itself
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5674 (let ((path (list dir)) path1 file files)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5675 (while (setq dir (pop path))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5676 (when (file-directory-p dir)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5677 (setq files (nreverse (directory-files dir t "[^.]")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5678 (while (setq file (pop files))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5679 (if (file-directory-p file)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5680 (push (file-name-as-directory file) path)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5681 (push dir path1)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5682 path1))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5683
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5684 (defun reftex-uniq (list)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5685 (let (new)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5686 (while list
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5687 (or (member (car list) new)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5688 (push (car list) new))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5689 (pop list))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5690 (nreverse new)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5691
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5692 ;;; =========================================================================
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5693 ;;;
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5694 ;;; Some generally useful functions
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5695
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5696 (defun reftex-no-props (string)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5697 ;; Return STRING with all text properties removed
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5698 (and (stringp string)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5699 (set-text-properties 0 (length string) nil string))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5700 string)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5701
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5702 (defun reftex-match-string (n)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5703 ;; Match string without properties
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5704 (when (match-beginning n)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5705 (buffer-substring-no-properties (match-beginning n) (match-end n))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5706
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5707 (defun reftex-kill-buffer (buffer)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5708 ;; Kill buffer if it exists.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5709 (and (setq buffer (get-buffer buffer))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5710 (kill-buffer buffer)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5711
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5712 (defun reftex-erase-buffer (&optional buffer)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5713 ;; Erase BUFFER if it exists. BUFFER defaults to current buffer.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5714 ;; This even erases read-only buffers.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5715 (cond
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5716 ((null buffer)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5717 ;; erase current buffer
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5718 (let ((buffer-read-only nil)) (erase-buffer)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5719 ((setq buffer (get-buffer buffer))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5720 ;; buffer exists
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5721 (save-excursion
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5722 (set-buffer buffer)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5723 (let ((buffer-read-only nil)) (erase-buffer))))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5724
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5725 (defun reftex-this-word (&optional class)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5726 ;; Grab the word around point.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5727 (setq class (or class "-a-zA-Z0-9:_/.*;|"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5728 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5729 (buffer-substring-no-properties
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5730 (progn (skip-chars-backward class) (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5731 (progn (skip-chars-forward class) (point)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5732
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5733 (defun reftex-all-assq (key list)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5734 ;; Return a list of all associations of KEY in LIST. Comparison with eq.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5735 (let (rtn)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5736 (while (setq list (memq (assq key list) list))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5737 (push (car list) rtn)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5738 (pop list))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5739 (nreverse rtn)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5740
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5741 (defun reftex-all-assoc-string (key list)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5742 ;; Return a list of all associations of KEY in LIST. Comparison with string=.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5743 (let (rtn)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5744 (while list
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5745 (if (string= (car (car list)) key)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5746 (push (car list) rtn))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5747 (pop list))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5748 (nreverse rtn)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5749
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5750 (defun reftex-last-assoc-before-elt (key elt list)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5751 ;; Find the last association of KEY in LIST before or at ELT
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5752 ;; ELT is found in LIST with equal, not eq.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5753 ;; Returns nil when either KEY or elt are not found in LIST.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5754 ;; On success, returns the association.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5755 (let* ((elt (car (member elt list))) ass last-ass)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5756
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5757 (while (and (setq ass (assoc key list))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5758 (setq list (memq ass list))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5759 (memq elt list))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5760 (setq last-ass ass
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5761 list (cdr list)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5762 last-ass))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5763
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5764 (defun reftex-truncate (string ncols &optional ellipses padding)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5765 ;; Truncate STRING to NCOLS characters.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5766 ;; When PADDING is non-nil, and string is shorter than NCOLS, fill with
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5767 ;; white space to NCOLS characters. When ELLIPSES is non-nil and the
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5768 ;; string needs to be truncated, replace last 3 characters by dots.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5769 (setq string
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5770 (if (<= (length string) ncols)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5771 string
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5772 (if ellipses
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5773 (concat (substring string 0 (- ncols 3)) "...")
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5774 (substring string 0 ncols))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5775 (if padding
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5776 (format (format "%%-%ds" ncols) string)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5777 string))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5778
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5779 (defun reftex-nearest-match (regexp &optional pos)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5780 ;; Find the nearest match of REGEXP. Set the match data.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5781 ;; If POS is given, calculate distances relative to it.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5782 ;; Return nil if there is no match.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5783 (let ((start (point)) (pos (or pos (point))) match1 match2 match)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5784 (goto-char start)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5785 (when (re-search-backward regexp nil t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5786 (setq match1 (match-data)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5787 (goto-char start)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5788 (when (re-search-forward regexp nil t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5789 (setq match2 (match-data)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5790 (goto-char start)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5791 (setq match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5792 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5793 ((not match1) match2)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5794 ((not match2) match1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5795 ((< (abs (- pos (car match1))) (abs (- pos (car match2)))) match1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5796 (t match2)))
21170
dbe101f49d57 (reftex-nearest-match): store-match-data => set-match-data.
Richard M. Stallman <rms@gnu.org>
parents: 21130
diff changeset
5797 (if match (progn (set-match-data match) t) nil)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5798
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5799 (defun reftex-auto-mode-alist ()
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5800 ;; Return an `auto-mode-alist' with only the .gz (etc) thingies.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5801 ;; Stolen from gnus nnheader.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5802 (let ((alist auto-mode-alist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5803 out)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5804 (while alist
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5805 (when (listp (cdr (car alist)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5806 (push (car alist) out))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5807 (pop alist))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5808 (nreverse out)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5809
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5810 (defun reftex-enlarge-to-fit (buf2 &optional keep-current)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5811 ;; Enlarge other window displaying buffer to show whole buffer if possible.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5812 ;; If KEEP-CURRENT in non-nil, current buffer must remain visible.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5813 (let* ((win1 (selected-window))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5814 (buf1 (current-buffer))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5815 (win2 (get-buffer-window buf2)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5816 (when win2
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5817 (select-window win2)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5818 (unless (and (pos-visible-in-window-p 1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5819 (pos-visible-in-window-p (point-max)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5820 (enlarge-window (1+ (- (count-lines 1 (point-max))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5821 (window-height))))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5822 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5823 ((window-live-p win1) (select-window win1))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5824 (keep-current
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5825 ;; we must have the old buffer!
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5826 (switch-to-buffer-other-window buf1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5827 (shrink-window (- (window-height) window-min-height))))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5828
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5829 (defun reftex-select-with-char (prompt help-string &optional delay-time scroll)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5830 ;; Offer to select something with PROMPT and, after DELAY-TIME seconds,
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5831 ;; also with HELP-STRING.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5832 ;; When SCROLL is non-nil, use SPC and DEL to scroll help window.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5833 (let ((char ?\?))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5834 (save-window-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5835 (catch 'exit
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5836 (message (concat prompt " (?=Help)"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5837 (when (or (sit-for (or delay-time 0))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5838 (= ?\? (setq char (read-char-exclusive))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5839 (with-output-to-temp-buffer " *RefTeX Help*"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5840 (princ help-string))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5841 (reftex-enlarge-to-fit " *RefTeX Help*")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5842 (select-window (get-buffer-window " *RefTeX Help*"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5843 (setq truncate-lines t))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5844 (setq prompt (concat prompt (if scroll " (SPC/DEL=Scroll)" "")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5845 (message prompt)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5846 (and (equal char ?\?) (setq char (read-char-exclusive)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5847 (while t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5848 (cond ((equal char ?\C-g) (keyboard-quit))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5849 ((equal char ?\?))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5850 ((and scroll (equal char ?\ ))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5851 (condition-case nil (scroll-up) (error nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5852 (message prompt))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5853 ((and scroll (equal char ?\C-? ))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5854 (condition-case nil (scroll-down) (error nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5855 (message prompt))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5856 (t (throw 'exit char)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5857 (setq char (read-char-exclusive)))))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5858
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5859 (defun reftex-make-regexp-allow-for-ctrl-m (string)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5860 ;; convert STRING into a regexp, allowing ^M for \n and vice versa
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5861 (let ((start -2))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5862 (setq string (regexp-quote string))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5863 (while (setq start (string-match "[\n\r]" string (+ 3 start)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5864 (setq string (replace-match "[\n\r]" nil t string)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5865 string))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5866
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5867 (defun reftex-get-buffer-visiting (file)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5868 ;; return a buffer visiting FILE
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5869 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5870 ((boundp 'find-file-compare-truenames) ; XEmacs
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5871 (let ((find-file-compare-truenames t))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5872 (get-file-buffer file)))
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5873 ((fboundp 'find-buffer-visiting) ; Emacs
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5874 (find-buffer-visiting file))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5875 (t (error "This should not happen (reftex-get-buffer-visiting)"))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5876
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5877 ;; Define `current-message' for compatibility with XEmacs prior to 20.4
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5878 (defvar message-stack)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5879 (if (and (featurep 'xemacs)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5880 (not (fboundp 'current-message)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5881 (defun current-message (&optional frame)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5882 (cdr (car message-stack))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5883
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5884 (defun reftex-visited-files (list)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5885 ;; Takes a list of filenames and returns the buffers of those already visited
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5886 (delq nil (mapcar (lambda (x) (if (reftex-get-buffer-visiting x) x nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5887 list)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5888
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5889 (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
5890 ;; Return a buffer visiting file. Make one, if necessary.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5891 ;; If neither such a buffer nor the file exist, return nil.
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5892 ;; If MARK-TO-KILL is t and there is no live buffer, visit the file with
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5893 ;; initializations according to `reftex-initialize-temporary-buffers',
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5894 ;; and mark the buffer to be killed after use.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5895
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5896 (let ((buf (reftex-get-buffer-visiting file)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5897
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5898 (cond (buf
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5899 ;; We have it already as a buffer - just return it
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5900 buf)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5901
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5902 ((file-readable-p file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5903 ;; At least there is such a file and we can read it.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5904
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5905 (if (or (not mark-to-kill)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5906 (eq t reftex-initialize-temporary-buffers))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5907
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5908 ;; Visit the file with full magic
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5909 (setq buf (find-file-noselect file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5910
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5911 ;; Else: Visit the file just briefly, without or
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5912 ;; with limited Magic
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5913
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5914 ;; The magic goes away
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5915 (let ((format-alist nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5916 (auto-mode-alist (reftex-auto-mode-alist))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5917 (default-major-mode 'fundamental-mode)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5918 (enable-local-variables nil)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5919 (after-insert-file-functions nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5920 (setq buf (find-file-noselect file)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5921
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5922 ;; Is there a hook to run?
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5923 (when (listp reftex-initialize-temporary-buffers)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5924 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5925 (set-buffer buf)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5926 (run-hooks 'reftex-initialize-temporary-buffers))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5927
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5928 ;; Lets see if we got a license to kill :-|
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5929 (and mark-to-kill
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5930 (add-to-list 'reftex-buffers-to-kill buf))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5931
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5932 ;; Return the new buffer
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5933 buf)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5934
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5935 ;; If no such file exists, return nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5936 (t nil))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5937
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5938 (defun reftex-kill-temporary-buffers (&optional buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5939 ;; Kill all buffers in the list reftex-kill-temporary-buffers.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5940 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5941 (buffer
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5942 (when (member buffer reftex-buffers-to-kill)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5943 (kill-buffer buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5944 (setq reftex-buffers-to-kill
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5945 (delete buffer reftex-buffers-to-kill))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5946 (t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5947 (while (setq buffer (pop reftex-buffers-to-kill))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5948 (when (bufferp buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5949 (and (buffer-modified-p buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5950 (y-or-n-p (format "Save file %s? "
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5951 (buffer-file-name buffer)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5952 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5953 (set-buffer buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5954 (save-buffer)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5955 (kill-buffer buffer))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5956 (pop reftex-buffers-to-kill)))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5957
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5958 (defun reftex-splice-symbols-into-list (list alist)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5959 ;; Splice the association in ALIST of any symbols in LIST into the list.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5960 ;; Return new list.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5961 (let (rtn tmp)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5962 (while list
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5963 (while (and (not (null (car list))) ;; keep list elements nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5964 (symbolp (car list)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5965 (setq tmp (car list))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5966 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5967 ((assoc tmp alist)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
5968 (setq list (append (nth 2 (assoc tmp alist)) (cdr list))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5969 (t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5970 (error "Cannot treat symbol %s in reftex-label-alist"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5971 (symbol-name tmp)))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5972 (push (pop list) rtn))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5973 (nreverse rtn)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5974
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5975 (defun reftex-uniquify-by-car (alist &optional keep-list)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
5976 ;; 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
5977 ;; Elements of KEEP-LIST are not removed even if duplicate.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5978 (let (new elm)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5979 (while alist
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5980 (setq elm (pop alist))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5981 (if (or (member (car elm) keep-list)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5982 (not (assoc (car elm) new)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5983 (push elm new)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5984 (nreverse new)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5985
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5986 ;;; =========================================================================
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5987 ;;;
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5988 ;;; Fontification and Highlighting
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5989
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5990 (defun reftex-use-fonts ()
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
5991 ;; Return t if we can and want to use fonts.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5992 (and window-system
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5993 reftex-use-fonts
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5994 (featurep 'font-lock)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5995
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5996 (defun reftex-refontify ()
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5997 ;; Return t if we need to refontify context
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5998 (and (reftex-use-fonts)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5999 (or (eq t reftex-refontify-context)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6000 (and (eq 1 reftex-refontify-context)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6001 ;; Test of we use the font-lock version of x-symbol
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6002 (and (featurep 'x-symbol-tex) (not (boundp 'x-symbol-mode)))))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6003
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6004 (defun reftex-fontify-select-label-buffer (parent-buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6005 ;; Fontify the `*RefTeX Select*' buffer. Buffer is temporarily renamed to
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6006 ;; start with none-SPC char, beacuse Font-Lock otherwise refuses operation.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6007 (run-hook-with-args 'reftex-pre-refontification-functions
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6008 parent-buffer 'reftex-ref)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6009 (let* ((oldname (buffer-name))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6010 (newname (concat "Fontify-me-" oldname)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6011 (unwind-protect
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6012 (progn
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6013 ;; Rename buffer temporarily to start w/o space (because of font-lock)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6014 (rename-buffer newname t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6015 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6016 ((fboundp 'font-lock-default-fontify-region)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6017 ;; Good: we have the indirection functions
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6018 (set (make-local-variable 'font-lock-fontify-region-function)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6019 'reftex-select-font-lock-fontify-region)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6020 (let ((major-mode 'latex-mode))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6021 (font-lock-mode 1)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6022 ((fboundp 'font-lock-set-defaults-1)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6023 ;; Looks like the XEmacs font-lock stuff.
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
6024 ;; FIXME: this is still kind of a hack, but it works.
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6025 (set (make-local-variable 'font-lock-keywords) nil)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6026 (let ((major-mode 'latex-mode)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6027 (font-lock-defaults-computed nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6028 (font-lock-set-defaults-1)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6029 (reftex-select-font-lock-fontify-region (point-min) (point-max))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6030 (t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6031 ;; Oops?
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6032 (message "Sorry: cannot refontify RefTeX Select buffer."))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6033 (rename-buffer oldname))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6034
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6035 (defun reftex-select-font-lock-fontify-region (beg end &optional loudly)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6036 ;; Fontify a region, but only lines starting with a dot.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6037 (let ((func (if (fboundp 'font-lock-default-fontify-region)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6038 'font-lock-default-fontify-region
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6039 'font-lock-fontify-region))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6040 beg1 end1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6041 (goto-char beg)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6042 (while (re-search-forward "^\\." end t)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6043 (setq beg1 (point) end1 (progn (skip-chars-forward "^\n") (point)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6044 (funcall func beg1 end1 nil)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6045 (goto-char end1))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6046
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6047 (defun reftex-select-font-lock-unfontify (&rest ignore) t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6048
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6049 (defun reftex-verified-face (&rest faces)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6050 ;; Return the first valid face in FACES, or nil if none is valid.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6051 ;; Also, when finding a nil element in FACES, return nil. This
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6052 ;; function is just a safety net to catch name changes of builtin
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6053 ;; fonts. Currently it is only used for reftex-label-face, which has
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6054 ;; as default font-lock-reference-face, which was recently renamed
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6055 ;; to font-lock-constant-face.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6056 (let (face)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6057 (catch 'exit
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6058 (while (setq face (pop faces))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6059 (if (featurep 'xemacs)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6060 (if (find-face face) (throw 'exit face))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6061 (if (facep face) (throw 'exit face)))))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6062
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6063 ;; Highlighting uses overlays. For XEmacs, we need the emulation.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6064 (if (featurep 'xemacs) (require 'overlay))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6065
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6066 ;; We keep a vector with several different overlays to do our highlighting.
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
6067 (defvar reftex-highlight-overlays [nil nil])
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6068
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6069 ;; Initialize the overlays
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6070 (aset reftex-highlight-overlays 0 (make-overlay 1 1))
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
6071 (overlay-put (aref reftex-highlight-overlays 0)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
6072 'face 'highlight)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6073 (aset reftex-highlight-overlays 1 (make-overlay 1 1))
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
6074 (overlay-put (aref reftex-highlight-overlays 1)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
6075 'face reftex-cursor-selected-face)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6076
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6077 ;; Two functions for activating and deactivation highlight overlays
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6078 (defun reftex-highlight (index begin end &optional buffer)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6079 "Highlight a region with overlay INDEX."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6080 (move-overlay (aref reftex-highlight-overlays index)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6081 begin end (or buffer (current-buffer))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6082 (defun reftex-unhighlight (index)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6083 "Detach overlay INDEX."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6084 (delete-overlay (aref reftex-highlight-overlays index)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6085
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6086 (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
6087 ;; Function used in pre-command-hook to remove highlights.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6088 (remove-hook 'pre-command-hook 'reftex-highlight-shall-die)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6089 (reftex-unhighlight 0))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6090
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6091 ;;; =========================================================================
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6092 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6093 ;;; Functions to compile the tables, reset the mode etc.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6094
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6095 ;; A list of all variables in the cache.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6096 ;; The cache is used to save the compiled versions of some variables.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6097 (defconst reftex-cache-variables
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6098 '(reftex-memory ;; This MUST ALWAYS be the first!
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6099 reftex-env-or-mac-alist reftex-everything-regexp
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6100 reftex-find-label-regexp-format reftex-find-label-regexp-format2
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6101 reftex-label-env-list reftex-label-mac-list
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6102 reftex-section-or-include-regexp reftex-section-levels-all
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6103 reftex-section-regexp reftex-type-query-help
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6104 reftex-type-query-prompt reftex-typekey-list
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6105 reftex-typekey-to-format-alist reftex-typekey-to-prefix-alist
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6106 reftex-words-to-typekey-alist))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6107
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6108 (defun reftex-ensure-compiled-variables ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6109 ;; Recompile the label alist when necessary
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6110 (let* ((mem reftex-memory)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6111 (cache (get reftex-docstruct-symbol 'reftex-cache))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6112 (cmem (car cache))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6113 (alist reftex-label-alist)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6114 (levels (get reftex-docstruct-symbol 'reftex-section-levels))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6115 (style (get reftex-docstruct-symbol 'reftex-label-alist-style))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6116 (default reftex-default-label-alist-entries))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6117 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6118 (reftex-tables-dirty (reftex-compile-variables))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6119 ((and (eq alist (nth 0 mem))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6120 (eq levels (nth 1 mem))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6121 (eq style (nth 2 mem))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6122 (eq default (nth 3 mem)))) ;; everything is OK
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6123 ((and (eq alist (nth 0 cmem))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6124 (eq levels (nth 1 cmem))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6125 (eq style (nth 2 cmem))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6126 (eq default (nth 2 cmem)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6127 ;; restore the cache
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6128 (message "Restoring cache")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6129 (mapcar (lambda (sym) (set sym (pop cache))) reftex-cache-variables))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6130 (t (reftex-compile-variables)))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6131
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6132 (defun reftex-reset-mode ()
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6133 "Reset RefTeX Mode.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6134 This will re-compile the configuration information and remove all
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6135 current scanning information and the parse file to enforce a rescan
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6136 on next use."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6137 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6138
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6139 ;; Reset the file search path variables
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6140 (loop for prop in '(status master-dir recursive-path rec-type) do
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6141 (put 'reftex-tex-path prop nil)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6142 (put 'reftex-bib-path prop nil))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6143
18219
aaeaae005e98 Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents: 18123
diff changeset
6144 ;; 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
6145 ;; were not cleaned up properly
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6146 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6147 (let ((buffer-list '("*RefTeX Help*" "*RefTeX Select*"
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6148 "*Duplicate Labels*" "*toc*" " *RefTeX-scratch*"))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6149 buf)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6150 (while (setq buf (pop buffer-list))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6151 (if (get-buffer buf)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6152 (kill-buffer buf))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6153 (reftex-erase-all-selection-buffers))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6154
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6155 ;; Make sure the current document will be rescanned soon.
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
6156 (reftex-reset-scanning-information)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
6157
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6158 ;; Remove any parse info file
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6159 (reftex-access-parse-file 'kill)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6160
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6161 ;; Plug functions into AUCTeX if the user option says so.
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6162 (and reftex-plug-into-AUCTeX
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6163 (reftex-plug-into-AUCTeX))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6164
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6165 (reftex-compile-variables))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6166
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6167 (defun reftex-reset-scanning-information ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6168 "Reset the symbols containing information from buffer scanning.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6169 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
6170 (if (string= reftex-last-toc-master (reftex-TeX-master-file))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
6171 (reftex-erase-buffer "*toc*"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6172 (let ((symlist reftex-multifile-symbols)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6173 symbol)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6174 (while symlist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6175 (setq symbol (car symlist)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6176 symlist (cdr symlist))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6177 (if (and (symbolp (symbol-value symbol))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6178 (not (null (symbol-value symbol))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6179 (set (symbol-value symbol) nil)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6180
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6181 (defun reftex-erase-all-selection-buffers ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6182 ;; Remove all selection buffers associated with current document.
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6183 (mapcar
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6184 (lambda (type)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6185 (reftex-erase-buffer (reftex-make-selection-buffer-name type)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6186 reftex-typekey-list))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6187
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6188 (defun reftex-compile-variables ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6189 ;; Compile the information in reftex-label-alist & Co.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6190
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6191 (message "Compiling label environment definitions...")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6192
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6193 ;; Update AUCTeX style information
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6194 (when (and (featurep 'tex-site) (fboundp 'TeX-update-style))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6195 (condition-case nil (TeX-update-style) (error nil)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6196
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6197 ;; Record that we have done this, and what we have used.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6198 (setq reftex-tables-dirty nil)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6199 (setq reftex-memory
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6200 (list reftex-label-alist
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6201 (get reftex-docstruct-symbol 'reftex-section-levels)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6202 (get reftex-docstruct-symbol 'reftex-label-alist-style)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6203 reftex-default-label-alist-entries))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6204
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6205 ;; Compile information in reftex-label-alist
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6206 (let ((all (reftex-uniquify-by-car
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6207 (reftex-splice-symbols-into-list
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6208 (append reftex-label-alist
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6209 (get reftex-docstruct-symbol 'reftex-label-alist-style)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6210 reftex-default-label-alist-entries)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6211 reftex-label-alist-builtin)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6212 '(nil)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6213 entry env-or-mac typekeychar typekey prefix context word
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6214 fmt reffmt labelfmt wordlist qh-list macros-with-labels
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6215 nargs nlabel opt-args cell sum i)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6216
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6217 (setq reftex-words-to-typekey-alist nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6218 reftex-typekey-list nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6219 reftex-typekey-to-format-alist nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6220 reftex-typekey-to-prefix-alist nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6221 reftex-env-or-mac-alist nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6222 reftex-label-env-list nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6223 reftex-label-mac-list nil)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6224 (while all
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6225 (catch 'next-entry
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6226 (setq entry (car all)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6227 env-or-mac (car entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6228 entry (cdr entry)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6229 all (cdr all))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6230 (if (null env-or-mac)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6231 (setq env-or-mac ""))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6232 (if (stringp (car entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6233 ;; This is before version 2.00 - convert entry to new format
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6234 ;; This is just to keep old users happy
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6235 (setq entry (cons (string-to-char (car entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6236 (cons (concat (car entry) ":")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6237 (cdr entry)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6238 (setq typekeychar (nth 0 entry)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6239 typekey (if typekeychar (char-to-string typekeychar) nil)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6240 prefix (nth 1 entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6241 fmt (nth 2 entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6242 context (nth 3 entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6243 wordlist (nth 4 entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6244 (if (stringp wordlist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6245 ;; This is before version 2.04 - convert to new format
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6246 (setq wordlist (nthcdr 4 entry)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6247
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6248 (if (and (stringp fmt)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6249 (string-match "@" fmt))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6250 ;; Special syntax for specifying a label format
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6251 (setq fmt (split-string fmt "@+"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6252 (setq fmt (list "\\label{%s}" fmt)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6253 (setq labelfmt (car fmt)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6254 reffmt (nth 1 fmt))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6255 ;; Note a new typekey
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6256 (if typekey
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6257 (add-to-list 'reftex-typekey-list typekey))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6258 (if (and typekey prefix
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6259 (not (assoc typekey reftex-typekey-to-prefix-alist)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6260 (add-to-list 'reftex-typekey-to-prefix-alist
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6261 (cons typekey prefix)))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6262 ;; Check if this is a macro or environment
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6263 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6264 ((string-match "\\`\\\\" env-or-mac)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6265 ;; It's a macro
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6266 (let ((result (reftex-parse-args env-or-mac)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6267 (setq env-or-mac (or (first result) env-or-mac)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6268 nargs (second result)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6269 nlabel (third result)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6270 opt-args (fourth result))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6271 (if nlabel (add-to-list 'macros-with-labels env-or-mac)))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6272 (if typekey (add-to-list 'reftex-label-mac-list env-or-mac)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6273 (t
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6274 ;; It's an environment
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6275 (setq nargs nil nlabel nil opt-args nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6276 (cond ((string= env-or-mac "any"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6277 ((string= env-or-mac ""))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6278 ((string= env-or-mac "section"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6279 (t
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6280 (add-to-list 'reftex-label-env-list env-or-mac)))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6281 ;; Translate some special context cases
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6282 (when (assq context reftex-default-context-regexps)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6283 (setq context
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6284 (format
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6285 (cdr (assq context reftex-default-context-regexps))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6286 (regexp-quote env-or-mac))))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6287 ;; See if this is the first format for this typekey
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6288 (and reffmt
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6289 (not (assoc typekey reftex-typekey-to-format-alist))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6290 (push (cons typekey reffmt) reftex-typekey-to-format-alist))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6291 ;; See if this is the first definition for this env-or-mac
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6292 (and (not (string= env-or-mac "any"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6293 (not (string= env-or-mac ""))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6294 (not (assoc env-or-mac reftex-env-or-mac-alist))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6295 (push (list env-or-mac typekey context labelfmt
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6296 nargs nlabel opt-args)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6297 reftex-env-or-mac-alist))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6298 ;; Are the magic words regular expressions? Quote normal words.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6299 (if (eq (car wordlist) 'regexp)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6300 (setq wordlist (cdr wordlist))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6301 (setq wordlist (mapcar 'regexp-quote wordlist)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6302 ;; Remember the first association of each word.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6303 (while (stringp (setq word (pop wordlist)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6304 (or (assoc word reftex-words-to-typekey-alist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6305 (push (cons word typekey) reftex-words-to-typekey-alist)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6306 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6307 ((string= "" env-or-mac) nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6308 ((setq cell (assoc typekey qh-list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6309 (push env-or-mac (cdr cell)))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6310 (typekey
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6311 (push (list typekey env-or-mac) qh-list)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6312
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6313 (setq reftex-typekey-to-prefix-alist
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6314 (nreverse reftex-typekey-to-prefix-alist))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6315
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6316 ;; Prepare the typekey query prompt and help string.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6317 (setq qh-list
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6318 (sort qh-list (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6319 (lambda (x1 x2) (string< (car x1) (car x2))))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6320 (setq reftex-type-query-prompt
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6321 (concat "Label type: ["
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6322 (mapconcat (function (lambda(x) (format "%s" (car x))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6323 qh-list "")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6324 "]"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6325 ;; In the help string, we need to wrap lines...
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6326 (setq reftex-type-query-help
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6327 (concat
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6328 "SELECT A LABEL TYPE:\n--------------------\n"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6329 (mapconcat
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6330 (lambda(x)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6331 (setq sum 0)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6332 (format " [%s] %s"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6333 (car x)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6334 (mapconcat (lambda(env)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6335 (setq sum (+ sum (length env)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6336 (if (< sum 60)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6337 env
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6338 (setq sum 0)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6339 (concat "\n " env)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6340 (cdr x) " ")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6341 qh-list "\n")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6342
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6343 ;; Convert magic words to regular expressions. We make regular expressions
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6344 ;; which allow for some chars from the ref format to be in the buffer.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6345 ;; These characters will be seen and removed.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6346 (setq reftex-words-to-typekey-alist
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6347 (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6348 (lambda (x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6349 (setq word (car x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6350 typekey (cdr x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6351 fmt (cdr (assoc typekey reftex-typekey-to-format-alist)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6352 (setq word (concat "\\W\\(" word "[ \t\n\r]*\\)\\("))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6353 (setq i 0)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6354 (while (and (< i 10) ; maximum number of format chars allowed
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6355 (< i (length fmt))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6356 (not (member (aref fmt i) '(?%))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6357 (setq word (concat word "\\|" (regexp-quote
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6358 (substring fmt 0 (1+ i)))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6359 (incf i))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6360 (cons (concat word "\\)\\=") typekey))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6361 (nreverse reftex-words-to-typekey-alist)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6362
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6363 ;; Make the full list of section levels
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6364 (setq reftex-section-levels-all
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6365 (append (get reftex-docstruct-symbol 'reftex-section-levels)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6366 reftex-section-levels))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6367
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6368 ;; Calculate the regular expressions
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6369 (let* ((wbol "\\(\\`\\|[\n\r]\\)[ \t]*")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6370 (label-re "\\\\label{\\([^}]*\\)}")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6371 (include-re (concat wbol "\\\\\\(include\\|input\\)[{ \t]+\\([^} \t\n\r]+\\)"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6372 (section-re
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6373 (concat wbol "\\\\\\("
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6374 (mapconcat 'car reftex-section-levels-all "\\|")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6375 "\\)\\*?\\(\\[[^]]*\\]\\)?{"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6376 (appendix-re (concat wbol "\\(\\\\appendix\\)"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6377 (macro-re
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6378 (if macros-with-labels
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6379 (concat "\\("
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6380 (mapconcat 'regexp-quote macros-with-labels "\\|")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6381 "\\)[[{]")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6382 ""))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6383 (find-label-re-format
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6384 (concat "\\("
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6385 (mapconcat 'regexp-quote (append '("\\label")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6386 macros-with-labels) "\\|")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6387 "\\)\\([[{][^]}]*[]}]\\)*[[{]\\(%s\\)[]}]")))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6388 (setq reftex-section-regexp section-re
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6389 reftex-section-or-include-regexp
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6390 (concat section-re "\\|" include-re)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6391 reftex-everything-regexp
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6392 (concat label-re "\\|" section-re "\\|" include-re
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6393 "\\|" appendix-re
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6394 (if macros-with-labels "\\|" "") macro-re)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6395 reftex-find-label-regexp-format find-label-re-format
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6396 reftex-find-label-regexp-format2
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6397 "\\([]} \t\n\r]\\)\\([[{]\\)\\(%s\\)[]}]")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6398 (message "Compiling label environment definitions...done")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6399 (put reftex-docstruct-symbol 'reftex-cache
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6400 (mapcar 'symbol-value reftex-cache-variables)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6401
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6402 ;;; =========================================================================
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6403 ;;;
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6404 ;;; Operations on entire Multifile documents
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6405
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6406 (defun reftex-create-tags-file ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6407 "Create TAGS file by running `etags' on the current document.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6408 The TAGS file is also immediately visited with `visit-tags-table'."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6409 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6410 (reftex-access-scan-info current-prefix-arg)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6411 (let* ((master (reftex-TeX-master-file))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6412 (files (reftex-all-document-files))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6413 (cmd (format "etags %s" (mapconcat 'identity files " "))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6414 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6415 (set-buffer (reftex-get-buffer-visiting master))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6416 (message "Running etags to create TAGS file...")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6417 (shell-command cmd)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6418 (visit-tags-table "TAGS"))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6419
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6420 ;; History of grep commands.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6421 (defvar reftex-grep-history nil)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6422 (defvar reftex-grep-command "grep -n "
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6423 "Last grep command used in \\[reftex-grep-document]; default for next grep.")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6424
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6425 (defun reftex-grep-document (grep-cmd)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6426 "Run grep query through all files related to this document.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6427 With prefix arg, force to rescan document.
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
6428 No active TAGS table is required."
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6429
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6430 (interactive
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6431 (list (read-from-minibuffer "Run grep on document (like this): "
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6432 reftex-grep-command nil nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6433 'reftex-grep-history)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6434 (reftex-access-scan-info current-prefix-arg)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6435 (let* ((files (reftex-all-document-files t))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6436 (cmd (format
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6437 "%s %s" grep-cmd
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6438 (mapconcat 'identity files " "))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6439 (grep cmd)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6440
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6441 (defun reftex-search-document (&optional regexp)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
6442 "Regexp search through all files of the current document.
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6443 Starts always in the master file. Stops when a match is found.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6444 To continue searching for next match, use command \\[tags-loop-continue].
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
6445 No active TAGS table is required."
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6446 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6447 (let ((default (reftex-this-word)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6448 (unless regexp
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6449 (setq regexp (read-string (format "Search regexp in document [%s]: "
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6450 default))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6451 (if (string= regexp "") (setq regexp (regexp-quote default)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6452
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6453 (reftex-access-scan-info current-prefix-arg)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6454 (tags-search regexp (list 'reftex-all-document-files))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6455
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6456 (defun reftex-query-replace-document (&optional from to delimited)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
6457 "Run a query-replace-regexp of FROM with TO over the entire document.
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6458 Third arg DELIMITED (prefix arg) means replace only word-delimited matches.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6459 If you exit (\\[keyboard-quit] or ESC), you can resume the query replace
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6460 with the command \\[tags-loop-continue].
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
6461 No active TAGS table is required."
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6462 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6463 (let ((default (reftex-this-word)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6464 (unless from
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6465 (setq from (read-string (format "Replace regexp in document [%s]: "
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6466 default)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6467 (if (string= from "") (setq from (regexp-quote default))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6468 (unless to
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6469 (setq to (read-string (format "Replace regexp %s with: " from))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6470 (reftex-access-scan-info current-prefix-arg)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6471 (tags-query-replace from to (or delimited current-prefix-arg)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6472 (list 'reftex-all-document-files))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6473
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6474 (defun reftex-find-duplicate-labels ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6475 "Produce a list of all duplicate labels in the document."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6476
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6477 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6478
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6479 ;; Rescan the document to make sure
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6480 (reftex-access-scan-info t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6481
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6482 (let ((master (reftex-TeX-master-file))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6483 (cnt 0)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6484 (dlist
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6485 (mapcar
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6486 (function
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6487 (lambda (x)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6488 (let (x1)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6489 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6490 ((memq (car x)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6491 '(toc bof eof bib thebib label-numbers xr xr-doc
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6492 master-dir file-error bibview-cache appendix
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6493 is-multi))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6494 nil)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6495 (t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6496 (setq x1 (reftex-all-assoc-string
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6497 (car x) (symbol-value reftex-docstruct-symbol)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6498 (if (< 1 (length x1))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6499 (append (list (car x))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6500 (mapcar (function
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6501 (lambda(x)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6502 (abbreviate-file-name (nth 3 x))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6503 x1))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6504 (list nil)))))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6505 (reftex-uniquify-by-car (symbol-value reftex-docstruct-symbol)))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6506
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6507 (setq dlist (reftex-uniquify-by-car dlist))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6508 (if (null dlist) (error "No duplicate labels in document"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6509 (switch-to-buffer-other-window "*Duplicate Labels*")
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
6510 (set (make-local-variable 'TeX-master) master)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6511 (erase-buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6512 (insert " MULTIPLE LABELS IN CURRENT DOCUMENT:\n")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6513 (insert
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6514 " Move point to label and type `r' to run a query-replace on the label\n"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6515 " and its references. Type `q' to exit this buffer.\n\n")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6516 (insert " LABEL FILE\n")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6517 (insert " -------------------------------------------------------------\n")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6518 (use-local-map (make-sparse-keymap))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6519 (local-set-key [?q] (function
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6520 (lambda () "Kill this buffer." (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6521 (kill-buffer (current-buffer)) (delete-window))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6522 (local-set-key [?r] 'reftex-change-label)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6523 (while dlist
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6524 (when (and (car (car dlist))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6525 (cdr (car dlist)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6526 (incf cnt)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6527 (insert (mapconcat 'identity (car dlist) "\n ") "\n"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6528 (pop dlist))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6529 (goto-char (point-min))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6530 (when (= cnt 0)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6531 (kill-buffer (current-buffer))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6532 (delete-window)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6533 (message "Document does not contain duplicate labels."))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6534
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6535 (defun reftex-change-label (&optional from to)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6536 "Query replace FROM with TO in all \\label and \\ref commands.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6537 Works on the entire multifile document.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6538 If you exit (\\[keyboard-quit] or ESC), you can resume the query replace
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6539 with the command \\[tags-loop-continue].
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
6540 No active TAGS table is required."
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6541 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6542 (let ((default (reftex-this-word "-a-zA-Z0-9_*.:")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6543 (unless from
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6544 (setq from (read-string (format "Replace label globally [%s]: "
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6545 default))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6546 (if (string= from "") (setq from default))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6547 (unless to
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6548 (setq to (read-string (format "Replace label %s with: "
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6549 from))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6550 (reftex-query-replace-document
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6551 (concat "\\\\\\(label\\|[a-z]*ref\\){" (regexp-quote from) "}")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6552 (format "\\\\\\1{%s}" to))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6553
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6554 (defun reftex-renumber-simple-labels ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6555 "Renumber all simple labels in the document to make them sequentially.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6556 Simple labels are the ones created by RefTeX, consisting only of the
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6557 prefix and a number. After the command completes, all these labels will
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6558 have sequential numbers throughout the document. Any references to
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6559 the labels will be changed as well. For this, RefTeX looks at the
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6560 arguments of any macros which either start or end in the string `ref'.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6561 This command should be used with care, in particular in multifile
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6562 documents. You should not use it if another document refers to this
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6563 one with the `xr' package."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6564 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6565 ;; Resan the entire document
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6566 (reftex-access-scan-info 1)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6567 ;; Get some insurance
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6568 (if (and (reftex-is-multi)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6569 (not (yes-or-no-p "Replacing all simple labels in multiple files is risky. Continue? ")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6570 (error "Abort"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6571 ;; Make the translation list
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6572 (let* ((re-core (concat "\\("
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6573 (mapconcat 'cdr reftex-typekey-to-prefix-alist "\\|")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6574 "\\)"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6575 (label-re (concat "\\`" re-core "\\([0-9]+\\)\\'"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6576 (search-re (concat "{\\(" re-core "\\([0-9]+\\)\\)}"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6577 (error-fmt "Undefined label or reference %s. Ignore and continue? ")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6578 (label-numbers-alist (mapcar (lambda (x) (cons (cdr x) 0))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6579 reftex-typekey-to-prefix-alist))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6580 (files (reftex-all-document-files))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6581 (list (symbol-value reftex-docstruct-symbol))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6582 translate-alist n entry label new-label nr-cell changed-sequence)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6583
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6584 (while (setq entry (pop list))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6585 (when (and (stringp (car entry))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6586 (string-match label-re (car entry)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6587 (setq label (car entry)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6588 nr-cell (assoc (match-string 1 (car entry))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6589 label-numbers-alist))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6590 (if (assoc label translate-alist)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6591 (error "Duplicate label %s" label))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6592 (setq new-label (concat (match-string 1 (car entry))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6593 (incf (cdr nr-cell))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6594 (push (cons label new-label) translate-alist)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6595 (or (string= label new-label) (setq changed-sequence t))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6596
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6597 (unless changed-sequence
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6598 (error "Simple labels are already in correct sequence"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6599
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6600 ;; Save all document buffers before this operation
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6601 (reftex-save-all-document-buffers)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6602
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6603 ;; First test to check for erros
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6604 (setq n (reftex-translate
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6605 files search-re translate-alist error-fmt 'test))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6606
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6607 ;; Now the real thing.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6608 (if (yes-or-no-p
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6609 (format "Replace %d items at %d places in %d files? "
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6610 (length translate-alist) n (length files)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6611 (progn
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6612 (let ((inhibit-quit t)) ;; Do not disturb...
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6613 (reftex-translate
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6614 files search-re translate-alist error-fmt nil)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6615 (setq quit-flag nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6616 (if (and (reftex-is-multi)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6617 (yes-or-no-p "Save entire document? "))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6618 (reftex-save-all-document-buffers))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6619 ;; Rescan again...
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6620 (reftex-access-scan-info 1)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6621 (message "Done replacing simple labels."))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6622 (message "No replacements done"))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6623
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6624 (defun reftex-translate (files search-re translate-alist error-fmt test)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6625 ;; In FILES, look for SEARCH-RE and replace match 1 of it with
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6626 ;; its association in TRANSLATE-ALSIT.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6627 ;; If we do not find an association and TEST is non-nil, query
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6628 ;; to ignore the problematic string.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6629 ;; If TEST is nil, it is ignored without query.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6630 ;; Return the number of replacements.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6631 (let ((n 0) file label match-data buf macro pos cell)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6632 (while (setq file (pop files))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6633 (setq buf (reftex-get-file-buffer-force file))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6634 (unless buf
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6635 (error "No such file %s" file))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6636 (set-buffer buf)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6637 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6638 (save-restriction
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6639 (widen)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6640 (goto-char (point-min))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6641 (while (re-search-forward search-re nil t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6642 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6643 (backward-char)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6644 (setq label (reftex-match-string 1)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6645 cell (assoc label translate-alist)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6646 match-data (match-data)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6647 macro (reftex-what-macro 1)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6648 pos (cdr macro))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6649 (goto-char (or pos (point)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6650 (when (and macro
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6651 (or (looking-at "\\\\ref")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6652 (looking-at "\\\\[a-zA-Z]*ref[^a-zA-Z]")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6653 (looking-at "\\\\ref[a-zA-Z]*[^a-zA-Z]")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6654 (looking-at (format
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6655 reftex-find-label-regexp-format
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6656 (regexp-quote label)))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6657 ;; OK, we should replace it.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6658 (set-match-data match-data)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6659 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6660 ((and test (not cell))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6661 ;; We've got a problem
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6662 (unwind-protect
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6663 (progn
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6664 (reftex-highlight 1 (match-beginning 0) (match-end 0))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6665 (ding)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6666 (or (y-or-n-p (format error-fmt label))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6667 (error "Abort")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6668 (reftex-unhighlight 1)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6669 ((and test cell)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6670 (incf n))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6671 ((and (not test) cell)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6672 ;; Replace
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6673 (goto-char (match-beginning 1))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6674 (delete-region (match-beginning 1) (match-end 1))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6675 (insert (cdr cell)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6676 (t nil))))))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6677 n))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6678
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6679 (defun reftex-save-all-document-buffers ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6680 "Save all documents associated with the current document.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6681 The function is useful after a global action like replacing or renumbering
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6682 labels."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6683 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6684 (let ((files (reftex-all-document-files))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6685 file buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6686 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6687 (while (setq file (pop files))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6688 (setq buffer (reftex-get-buffer-visiting file))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6689 (when buffer
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6690 (set-buffer buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6691 (save-buffer))))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6692
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6693 ;;; =========================================================================
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6694 ;;;
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6695 ;;; AUCTeX Interface
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6696
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6697 (defun reftex-plug-flag (which)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6698 ;; Tell if a certain flag is set in reftex-plug-into-AUCTeX
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6699 (or (eq t reftex-plug-into-AUCTeX)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6700 (and (listp reftex-plug-into-AUCTeX)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6701 (nth which reftex-plug-into-AUCTeX))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6702
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6703 (defun reftex-arg-label (optional &optional prompt definition)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6704 "Use `reftex-label', `reftex-reference' or AUCTeX's code to insert label arg.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6705 What is being used depends upon `reftex-plug-into-AUCTeX'."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6706 (let (label)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6707 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6708 ((and definition (reftex-plug-flag 1))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6709 ;; Create a new label, with a temporary brace for `reftex-what-macro'
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6710 (unwind-protect
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6711 (progn (insert "{") (setq label (or (reftex-label nil t) "")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6712 (delete-backward-char 1)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6713 ((and (not definition) (reftex-plug-flag 2))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6714 ;; Reference a label with RefTeX
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6715 (setq label (reftex-reference nil t)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6716 (t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6717 ;; AUCTeX's default mechanism
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6718 (setq label (completing-read (TeX-argument-prompt optional prompt "Key")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6719 (LaTeX-label-list)))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6720 (if (and definition (not (string-equal "" label)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6721 (LaTeX-add-labels label))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6722 (TeX-argument-insert label optional optional)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6723
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6724 (defun reftex-arg-cite (optional &optional prompt definition)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6725 "Use `reftex-citation' or AUCTeX's code to insert a cite-key macro argument.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6726 What is being used depends upon `reftex-plug-into-AUCTeX'."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6727 (let (items)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6728 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6729 ((and (not definition) (reftex-plug-flag 3))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6730 (setq items (list (or (reftex-citation t) ""))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6731 (t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6732 (setq prompt (concat (if optional "(Optional) " "")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6733 (if prompt prompt "Add key")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6734 ": (default none) "))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6735 (setq items (multi-prompt "," t prompt (LaTeX-bibitem-list)))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6736 (apply 'LaTeX-add-bibitems items)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6737 (TeX-argument-insert (mapconcat 'identity items ",") optional optional)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6738
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6739 (defun reftex-plug-into-AUCTeX ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6740 ;; Replace AUCTeX functions with RefTeX functions.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6741 ;; Which functions are replaced is controlled by the variable
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6742 ;; `reftex-plug-into-AUCTeX'.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6743
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6744 (if (reftex-plug-flag 0)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6745 (setq LaTeX-label-function 'reftex-label)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6746 (setq LaTeX-label-function nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6747
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6748 (if (and (or (reftex-plug-flag 1) (reftex-plug-flag 2))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6749 (fboundp 'TeX-arg-label))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6750 (fset 'TeX-arg-label 'reftex-arg-label))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6751
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6752 (if (and (reftex-plug-flag 3)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6753 (fboundp 'TeX-arg-cite))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6754 (fset 'TeX-arg-cite 'reftex-arg-cite)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6755
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6756 (defun reftex-toggle-plug-into-AUCTeX ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6757 "Toggle Interface between AUCTeX and RefTeX on and off."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6758 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6759 (unless (and (featurep 'tex-site) (featurep 'latex))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6760 (error "AUCTeX's LaTeX mode does not seem to be loaded."))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6761 (setq reftex-plug-into-AUCTeX (not reftex-plug-into-AUCTeX))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6762 (reftex-plug-into-AUCTeX)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6763 (if reftex-plug-into-AUCTeX
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6764 (message "RefTeX has been plugged into AUCTeX.")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6765 (message "RefTeX no longer interacts with AUCTeX.")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6766
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6767 (defun reftex-add-label-environments (entry-list)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6768 "Add label environment descriptions to `reftex-label-alist-style'.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6769 The format of ENTRY-LIST is exactly like `reftex-label-alist'. See there
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6770 for details.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6771 This function makes it possible to support RefTeX from AUCTeX style files.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6772 The entries in ENTRY-LIST will be processed after the user settings in
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6773 `reftex-label-alist', and before the defaults (specified in
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6774 `reftex-default-label-alist-entries'). Any changes made to
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6775 `reftex-label-alist-style' will raise a flag to the effect that
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6776 the label information is recompiled on next use."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6777 (unless reftex-docstruct-symbol
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6778 (reftex-tie-multifile-symbols))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6779 (when (and reftex-docstruct-symbol
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6780 (symbolp reftex-docstruct-symbol))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6781 (let ((list (get reftex-docstruct-symbol 'reftex-label-alist-style))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6782 entry changed)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6783 (while entry-list
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6784 (setq entry (pop entry-list))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6785 (unless (member entry list)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6786 (setq reftex-tables-dirty t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6787 changed t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6788 (push entry list)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6789 (when changed
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6790 (put reftex-docstruct-symbol 'reftex-label-alist-style list)))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6791 (defalias 'reftex-add-to-label-alist 'reftex-add-label-environments)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6792
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6793 (defun reftex-add-section-levels (entry-list)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6794 "Add entries to the value of `reftex-section-levels'.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6795 The added values are kept local to the current document. The format
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6796 of ENTRY-LIST is a list of cons cells (\"MACRONAME\" . LEVEL). See
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6797 `reftex-section-levels' for an example."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6798 (unless reftex-docstruct-symbol
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6799 (reftex-tie-multifile-symbols))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6800 (when (and reftex-docstruct-symbol
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6801 (symbolp reftex-docstruct-symbol))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6802 (let ((list (get reftex-docstruct-symbol 'reftex-section-levels))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6803 entry changed)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6804 (while entry-list
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6805 (setq entry (pop entry-list))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6806 (unless (member entry list)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6807 (setq reftex-tables-dirty t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6808 changed t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6809 (push entry list)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6810 (when changed
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6811 (put reftex-docstruct-symbol 'reftex-section-levels list)))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6812
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6813 (defun reftex-set-cite-format (value)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6814 "Set the document-local value of `reftex-cite-format'.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6815 When such a value exists, it overwrites the setting given with
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6816 `reftex-cite-format'. See the documentation of `reftex-cite-format'
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6817 for possible values. This function should be used from AUCTeX style files."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6818 (unless reftex-docstruct-symbol
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6819 (reftex-tie-multifile-symbols))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6820 (when (and reftex-docstruct-symbol
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6821 (symbolp reftex-docstruct-symbol))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6822 (put reftex-docstruct-symbol 'reftex-cite-format value)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6823
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6824 (defun reftex-notice-new-section ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6825 "Hook to handshake with RefTeX after a new section has been inserted."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6826 ;; Add a new section to the docstruct list and renumber the
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6827 ;; following sections. This hook has to be called immediately after
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6828 ;; the new section was inserted into the buffer, and before the
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6829 ;; section label is created.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6830
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6831 (condition-case nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6832 (catch 'exit
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6833 (unless reftex-mode (throw 'exit nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6834 (reftex-access-scan-info)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6835 (let* ((docstruct (symbol-value reftex-docstruct-symbol))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6836 here-am-I appendix tail toc-entry star level
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6837 section-number context)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6838
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6839 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6840 (when (re-search-backward reftex-section-regexp nil t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6841
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6842 ;; Find where we are
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6843 (setq here-am-I (reftex-where-am-I))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6844 (unless (cdr here-am-I) (throw 'exit nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6845 (setq reftex-active-toc (reftex-last-assoc-before-elt
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6846 'toc (car here-am-I) docstruct)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6847 appendix (reftex-last-assoc-before-elt
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6848 'appendix (car here-am-I) docstruct))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6849
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6850 ;; Initialize section numbers
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6851 (if (eq (car (car here-am-I)) 'appendix)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6852 (reftex-init-section-numbers nil t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6853 (reftex-init-section-numbers reftex-active-toc appendix))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6854
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6855 ;; Match the section command
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6856 (when (and (re-search-forward reftex-everything-regexp nil t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6857 (match-end 3))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6858 (setq star (= ?* (char-after (match-end 3)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6859 toc-entry (reftex-section-info (buffer-file-name))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6860 level (nth 5 toc-entry)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6861 tail (memq (car here-am-I)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6862 (symbol-value reftex-docstruct-symbol)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6863 (if tail
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6864 ;; Insert the section info
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6865 (push toc-entry (cdr tail))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6866 (throw 'exit nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6867
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6868 ;; We are done unless we use section numbers
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6869 (unless (nth 1 reftex-label-menu-flags) (throw 'exit nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6870
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6871 ;; Update the remaining toc items
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6872 (setq tail (cdr tail))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6873 (while (and (setq tail (memq (assq 'toc (cdr tail)) tail))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6874 (setq toc-entry (car tail))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6875 (>= (nth 5 toc-entry) level))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6876 (setq section-number
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6877 (reftex-section-number (nth 5 toc-entry) star)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6878 context (nth 2 toc-entry))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6879 (when (string-match "\\`\\([ \t]*\\)\\([.0-9A-Z]+\\)\\(.*\\)"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6880 context)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6881 (when (and (not appendix)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6882 (>= (string-to-char (match-string 2)) ?A))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6883 ;; Just entered the appendex. Get out.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6884 (throw 'exit nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6885
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6886 ;; Change the section number.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6887 (setf (nth 2 toc-entry)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6888 (concat (match-string 1 context)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6889 section-number
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6890 (match-string 3 context))))))))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6891 (error nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6892 )
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6893
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6894 ;;; =========================================================================
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6895 ;;;
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6896 ;;; Keybindings
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6897
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6898 ;; The default bindings in the mode map.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6899 (loop for x in
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6900 '(("\C-c=" . reftex-toc)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6901 ("\C-c(" . reftex-label)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6902 ("\C-c)" . reftex-reference)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6903 ("\C-c[" . reftex-citation)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6904 ("\C-c&" . reftex-view-crossref))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6905 do (define-key reftex-mode-map (car x) (cdr x)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6906
21130
60e882bbb28b Added keybinding for `reftex-mouse-view-crossref' to S-mouse-2.
Carsten Dominik <dominik@science.uva.nl>
parents: 21124
diff changeset
6907 ;; Bind `reftex-mouse-view-crossref' only when the key is still free
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6908 (if (featurep 'xemacs)
21130
60e882bbb28b Added keybinding for `reftex-mouse-view-crossref' to S-mouse-2.
Carsten Dominik <dominik@science.uva.nl>
parents: 21124
diff changeset
6909 (unless (key-binding [(shift button2)])
60e882bbb28b Added keybinding for `reftex-mouse-view-crossref' to S-mouse-2.
Carsten Dominik <dominik@science.uva.nl>
parents: 21124
diff changeset
6910 (define-key reftex-mode-map [(shift button2)]
60e882bbb28b Added keybinding for `reftex-mouse-view-crossref' to S-mouse-2.
Carsten Dominik <dominik@science.uva.nl>
parents: 21124
diff changeset
6911 'reftex-mouse-view-crossref))
60e882bbb28b Added keybinding for `reftex-mouse-view-crossref' to S-mouse-2.
Carsten Dominik <dominik@science.uva.nl>
parents: 21124
diff changeset
6912 (unless (key-binding [(shift mouse-2)])
60e882bbb28b Added keybinding for `reftex-mouse-view-crossref' to S-mouse-2.
Carsten Dominik <dominik@science.uva.nl>
parents: 21124
diff changeset
6913 (define-key reftex-mode-map [(shift mouse-2)]
60e882bbb28b Added keybinding for `reftex-mouse-view-crossref' to S-mouse-2.
Carsten Dominik <dominik@science.uva.nl>
parents: 21124
diff changeset
6914 'reftex-mouse-view-crossref)))
60e882bbb28b Added keybinding for `reftex-mouse-view-crossref' to S-mouse-2.
Carsten Dominik <dominik@science.uva.nl>
parents: 21124
diff changeset
6915
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6916 ;; If the user requests so, she can have a few more bindings:
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6917 (when reftex-extra-bindings
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6918 (loop for x in
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6919 '(("\C-ct" . reftex-toc)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6920 ("\C-cl" . reftex-label)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6921 ("\C-cr" . reftex-reference)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6922 ("\C-cc" . reftex-citation)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6923 ("\C-cv" . reftex-view-crossref)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6924 ("\C-cg" . reftex-grep-document)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6925 ("\C-cs" . reftex-search-document))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6926 do (define-key reftex-mode-map (car x) (cdr x))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6927
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6928 ;; Common bindings in reftex-select-label-map and reftex-select-bib-map
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6929 (let ((map (make-sparse-keymap)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6930 (substitute-key-definition
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6931 'next-line 'reftex-select-next map global-map)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6932 (substitute-key-definition
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6933 'previous-line 'reftex-select-previous map global-map)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6934 (substitute-key-definition
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
6935 'keyboard-quit 'reftex-select-keyboard-quit map global-map)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6936 (substitute-key-definition
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6937 'newline 'reftex-select-accept map global-map)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6938
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6939 (loop for x in
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6940 '((" " . reftex-select-callback)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6941 ("n" . reftex-select-next)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6942 ([(down)] . reftex-select-next)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6943 ("p" . reftex-select-previous)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6944 ([(up)] . reftex-select-previous)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6945 ("f" . reftex-select-toggle-follow)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6946 ("\C-m" . reftex-select-accept)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6947 ([(return)] . reftex-select-accept)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6948 ("q" . reftex-select-quit)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6949 ("." . reftex-select-show-insertion-point)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6950 ("?" . reftex-select-help))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6951 do (define-key map (car x) (cdr x)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6952
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6953 ;; The mouse-2 binding
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6954 (if (featurep 'xemacs)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6955 (define-key map [(button2)] 'reftex-select-mouse-accept)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6956 (define-key map [(mouse-2)] 'reftex-select-mouse-accept))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6957
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6958 ;; Digit arguments
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
6959 (loop for key across "0123456789" do
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
6960 (define-key map (vector (list key)) 'digit-argument))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
6961 (define-key map "-" 'negative-argument)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6962
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6963 ;; Make two maps
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6964 (setq reftex-select-label-map map)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6965 (setq reftex-select-bib-map (copy-keymap map)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6966
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6967 ;; Specific bindings in reftex-select-label-map
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6968 (loop for key across "cgilrRstx#%" do
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6969 (define-key reftex-select-label-map (vector (list key))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6970 (list 'lambda '()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6971 "Press `?' during selection to find out about this key."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6972 '(interactive) (list 'throw '(quote myexit) key))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6973
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6974 (loop for x in
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6975 '(("b" . reftex-select-jump-to-previous)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6976 ("v" . reftex-select-toggle-varioref)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6977 ([(tab)] . reftex-select-read-label)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6978 ("\C-i" . reftex-select-read-label)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6979 ("\C-c\C-n" . reftex-select-next-heading)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6980 ("\C-c\C-p" . reftex-select-previous-heading))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6981 do
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6982 (define-key reftex-select-label-map (car x) (cdr x)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6983
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6984 ;; Specific bindings in reftex-select-bib-map
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6985 (loop for key across "grRaA" do
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6986 (define-key reftex-select-bib-map (vector (list key))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6987 (list 'lambda '()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6988 "Press `?' during selection to find out about this key."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6989 '(interactive) (list 'throw '(quote myexit) key))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6990
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6991 (loop for x in
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6992 '(("\C-i" . reftex-select-read-cite)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6993 ([(tab)] . reftex-select-read-cite))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6994 do (define-key reftex-select-bib-map (car x) (cdr x)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6995
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6996 ;; Table of Contents map
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6997 (if (featurep 'xemacs)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6998 (define-key reftex-toc-map [(button2)] 'reftex-toc-mouse-goto-line-and-hide)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6999 (define-key reftex-toc-map [(mouse-2)] 'reftex-toc-mouse-goto-line-and-hide))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7000
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7001 (substitute-key-definition
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7002 'next-line 'reftex-toc-next reftex-toc-map global-map)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7003 (substitute-key-definition
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7004 'previous-line 'reftex-toc-previous reftex-toc-map global-map)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7005
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7006 (loop for x in
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7007 '(("n" . reftex-toc-next)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7008 ("p" . reftex-toc-previous)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7009 ("?" . reftex-toc-show-help)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7010 (" " . reftex-toc-view-line)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7011 ("\C-m" . reftex-toc-goto-line-and-hide)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7012 ("\C-i" . reftex-toc-goto-line)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7013 ("r" . reftex-toc-rescan)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7014 ("R" . reftex-toc-Rescan)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7015 ("g" . revert-buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7016 ("q" . reftex-toc-quit)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7017 ("Q" . reftex-toc-quit-and-kill)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7018 ("f" . reftex-toc-toggle-follow)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7019 ("i" . reftex-toc-toggle-file-boundary)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7020 ("l" . reftex-toc-toggle-labels)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7021 ("c" . reftex-toc-toggle-context)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7022 ("%" . reftex-toc-toggle-commented)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7023 ("x" . reftex-toc-external)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7024 ("." . reftex-toc-show-calling-point))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7025 do (define-key reftex-toc-map (car x) (cdr x)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7026
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7027 (loop for key across "0123456789" do
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7028 (define-key reftex-toc-map (vector (list key)) 'digit-argument))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7029 (define-key reftex-toc-map "-" 'negative-argument)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
7030
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7031 ;;; =========================================================================
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7032 ;;;
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7033 ;;; Menu
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7034
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7035 ;; Define a menu for the menu bar if Emacs is running under X
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7036
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7037 (require 'easymenu)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7038
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7039 (easy-menu-define reftex-mode-menu reftex-mode-map
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7040 "Menu used in RefTeX mode"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
7041 `("Ref"
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
7042 ["Table of Contents" reftex-toc t]
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7043 "---"
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
7044 ["\\label" reftex-label t]
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
7045 ["\\ref" reftex-reference t]
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
7046 ["\\cite" reftex-citation t]
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
7047 ["View Crossref" reftex-view-crossref t]
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7048 "---"
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
7049 ("Parse Document"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
7050 ["Only this File" reftex-parse-one t]
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
7051 ["Entire Document" reftex-parse-all (reftex-is-multi)]
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
7052 ["Save to File" (reftex-access-parse-file 'write)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
7053 (> (length (symbol-value reftex-docstruct-symbol)) 0)]
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
7054 ["Restore from File" (reftex-access-parse-file 'restore) t]
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
7055 "---"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
7056 ["Reset RefTeX Mode" reftex-reset-mode t])
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
7057 ("Global Actions"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
7058 ["Search Whole Document" reftex-search-document t]
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
7059 ["Replace in Document" reftex-query-replace-document t]
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
7060 ["Grep on Document" reftex-grep-document t]
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7061 "---"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
7062 ["Create TAGS File" reftex-create-tags-file t]
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7063 "---"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
7064 ["Find Duplicate Labels" reftex-find-duplicate-labels t]
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
7065 ["Change Label and Refs" reftex-change-label t]
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7066 ["Renumber Simple Labels" reftex-renumber-simple-labels t]
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
7067 "---"
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7068 ["Save Document" reftex-save-all-document-buffers t])
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
7069 "---"
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7070 ("Options"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7071 ("Table of Contents"
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7072 ["Keep Other Windows" (setq reftex-toc-keep-other-windows
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7073 (not reftex-toc-keep-other-windows))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7074 :style toggle :selected reftex-toc-keep-other-windows]
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7075 ["Follow Mode" (setq reftex-toc-follow-mode (not reftex-toc-follow-mode))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7076 :style toggle :selected reftex-toc-follow-mode]
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7077 ["Follow Mode may Visit Files"
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7078 (setq reftex-revisit-to-follow (not reftex-revisit-to-follow))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7079 :style toggle :selected reftex-revisit-to-follow])
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7080 ("References"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7081 ["Guess Label Type"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7082 (setq reftex-guess-label-type (not reftex-guess-label-type))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7083 :style toggle :selected reftex-guess-label-type]
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7084 ["Use `\\vref' by Default"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7085 (setq reftex-vref-is-default (not reftex-vref-is-default))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7086 :style toggle :selected reftex-vref-is-default]
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7087 "---"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7088 "Selection Buffers"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7089 ["Use Multiple Buffers"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7090 (setq reftex-use-multiple-selection-buffers
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7091 (not reftex-use-multiple-selection-buffers))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7092 :style toggle :selected reftex-use-multiple-selection-buffers]
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7093 ["Auto Update Buffers"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7094 (setq reftex-auto-update-selection-buffers
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7095 (not reftex-auto-update-selection-buffers))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7096 :style toggle :selected reftex-auto-update-selection-buffers])
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7097 ("Citations"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7098 "Citation Style"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7099 ,@(mapcar
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7100 (function
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7101 (lambda (x)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7102 (vector
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7103 (capitalize (symbol-name (car x)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7104 (list 'reftex-set-cite-format (list 'quote (car x)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7105 ':style 'radio ':selected
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7106 (list 'eq (list 'reftex-get-cite-format) (list 'quote (car x))))))
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
7107 reftex-cite-format-builtin)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7108 "---"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7109 "Bibinfo in Comments"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7110 ["Attach Comments"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7111 (setq reftex-comment-citations (not reftex-comment-citations))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7112 :style toggle :selected reftex-comment-citations]
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7113 "---"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7114 "Sort Database Matches"
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7115 ["Not" (setq reftex-sort-bibtex-matches nil)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7116 :style radio :selected (eq reftex-sort-bibtex-matches nil)]
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7117 ["by Author" (setq reftex-sort-bibtex-matches 'author)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7118 :style radio :selected (eq reftex-sort-bibtex-matches 'author)]
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7119 ["by Year" (setq reftex-sort-bibtex-matches 'year)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7120 :style radio :selected (eq reftex-sort-bibtex-matches 'year)]
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7121 ["by Year, reversed" (setq reftex-sort-bibtex-matches 'reverse-year)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7122 :style radio :selected (eq reftex-sort-bibtex-matches 'reverse-year)])
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7123 ("Crossref Viewing"
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
7124 ["Automatic Info" reftex-toggle-auto-view-crossref
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7125 :style toggle :selected reftex-auto-view-crossref-timer]
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
7126 ["...in Echo Area" (setq reftex-auto-view-crossref t)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
7127 :style radio :selected (eq reftex-auto-view-crossref t)]
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
7128 ["...in Other Window" (setq reftex-auto-view-crossref 'window)
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
7129 :style radio :selected (eq reftex-auto-view-crossref 'window)]
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
7130 "---"
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7131 ["Crossref Echo may Visit Files"
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7132 (setq reftex-revisit-to-echo (not reftex-revisit-to-echo))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7133 :style toggle :selected reftex-revisit-to-echo]
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7134 ["Cache Echo Strings for \cite"
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7135 (setq reftex-cache-cite-echo (not reftex-cache-cite-echo))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7136 :style toggle :selected reftex-cache-cite-echo])
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7137 ("Parser"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7138 "Document Scans"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7139 ["Partial Scans"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7140 (setq reftex-enable-partial-scans (not reftex-enable-partial-scans))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7141 :style toggle :selected reftex-enable-partial-scans]
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7142 ["Auto-Save Parse Info"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7143 (setq reftex-save-parse-info (not reftex-save-parse-info))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7144 :style toggle :selected reftex-save-parse-info]
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7145 ["Automatic Rescans"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7146 (setq reftex-allow-automatic-rescan (not reftex-allow-automatic-rescan))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7147 :style toggle :selected reftex-allow-automatic-rescan]
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7148 "---"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7149 "Temporary Buffers"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7150 ["Keep Buffers"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7151 (setq reftex-keep-temporary-buffers (not reftex-keep-temporary-buffers))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7152 :style toggle :selected reftex-keep-temporary-buffers]
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7153 ["Initialize when Visiting"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7154 (setq reftex-initialize-temporary-buffers
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7155 (not reftex-initialize-temporary-buffers))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7156 :style toggle :selected reftex-initialize-temporary-buffers])
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7157 ("AUC TeX"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7158 ["Plug into AUC TeX" reftex-toggle-plug-into-AUCTeX
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7159 :style toggle :selected reftex-plug-into-AUCTeX])
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7160 ("Fontification"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7161 ["Use Fontification" (setq reftex-use-fonts (not reftex-use-fonts))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7162 :style toggle :selected reftex-use-fonts]
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7163 ["Fontify Context Display" (setq reftex-refontify-context
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7164 (not (reftex-refontify)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7165 :style toggle :selected (reftex-refontify)]))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7166 ;;"---"
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
7167 ("Customize"
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7168 ["Browse RefTeX Group" reftex-customize t]
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
7169 "---"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
7170 ["Build Full Customize Menu" reftex-create-customize-menu
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
7171 (fboundp 'customize-menu-create)])
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7172 "---"
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
7173 ("Documentation"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
7174 ["Info" reftex-info t]
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
7175 ["Commentary" reftex-show-commentary t])))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7176
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7177 (defun reftex-customize ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7178 "Call the customize function with reftex as argument."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7179 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7180 (customize-browse 'reftex))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7181
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7182 (defun reftex-create-customize-menu ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7183 "Create a full customization menu for RefTeX, insert it into the menu."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7184 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7185 (if (fboundp 'customize-menu-create)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7186 (progn
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7187 (easy-menu-change
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7188 '("Ref") "Customize"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7189 `(["Browse RefTeX group" reftex-customize t]
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7190 "---"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7191 ,(customize-menu-create 'reftex)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7192 ["Set" Custom-set t]
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7193 ["Save" Custom-save t]
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7194 ["Reset to Current" Custom-reset-current t]
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7195 ["Reset to Saved" Custom-reset-saved t]
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7196 ["Reset to Standard Settings" Custom-reset-standard t]))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7197 (message "\"Ref\"-menu now contains full customization menu"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7198 (error "Cannot expand menu (outdated version of cus-edit.el)")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7199
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7200 (defun reftex-show-commentary ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7201 "Use the finder to view the file documentation from `reftex.el'."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7202 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7203 (require 'finder)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7204 (finder-commentary "reftex.el"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7205
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7206 (defun reftex-info ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7207 "Read documentation for RefTeX in the info system."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7208 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7209 (require 'info)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7210 (Info-goto-node "(reftex)"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7211
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7212 ;;; Install the kill-buffer and kill-emacs hooks ------------------------------
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7213
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7214 (add-hook 'kill-buffer-hook 'reftex-kill-buffer-hook)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7215 (add-hook 'kill-emacs-hook 'reftex-kill-emacs-hook)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7216
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7217 ;;; Run Hook ------------------------------------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7218
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7219 (run-hooks 'reftex-load-hook)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7220
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7221 ;;; That's it! ----------------------------------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7222
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
7223 (setq reftex-tables-dirty t) ; in case this file is evaluated by hand
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
7224 (provide 'reftex)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
7225
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7226 ;;;============================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7227
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
7228 ;;; reftex.el ends here
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7229