annotate lisp/textmodes/reftex.el @ 25181:847441efad8d

(switch_to_buffer_1): New subroutine, taken out from Fswitch_to_buffer. (no_switch_buffer): New function. (Fswitch_to_buffer): Call them. Don't get confused by "same-window" buffers in a dedicated frame.
author Richard M. Stallman <rms@gnu.org>
date Thu, 05 Aug 1999 19:38:34 +0000
parents bd105cd3c084
children 03cb8fb8ab28
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 ;; ====================
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
70 ;;
23707
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.
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
75 ;;
23707
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
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
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 ;;
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
82 ;; Creating Labels
23707
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)
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
89 ;; This is configurable with the variable `reftex-insert-label-flags'.
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
90 ;;
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
91 ;; Referencing Labels
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
92 ;; 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
93 ;; 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
94 ;; (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
95 ;; 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
96 ;;
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
97 ;; 3. Citations
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
98 ;; 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
99 ;; 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
100 ;; 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
101 ;; 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
102 ;; sorted. The selected article is referenced as `\cite{KEY}' (see
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
103 ;; variable `reftex-cite-format').
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
104 ;;
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
105 ;; 4. Viewing Cross-References
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
106 ;; When point is on the KEY argument of a cross-referencing macro
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
107 ;; (`\label', `\ref', `\cite', `\bibitem', `\index', and variations)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
108 ;; or inside a BibTeX database entry, you can press `C-c &'
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
109 ;; (`reftex-view-crossref') to display corresponding locations in the
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
110 ;; document and associated BibTeX database files.
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
111 ;; When the enclosing macro is `\cite' or `\ref' and no other message
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
112 ;; occupies the echo area, information about the citation or label
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
113 ;; will automatically be displayed.
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
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
116 ;; Multifile Documents are fully supported. RefTeX provides
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
117 ;; cross-referencing information from all parts of the document, and
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
118 ;; 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)
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
431 (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
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)
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
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 '(
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
585 ("part" . 0)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
586 ("chapter" . 1)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
587 ("section" . 2)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
588 ("subsection" . 3)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
589 ("subsubsection" . 4)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
590 ("paragraph" . 5)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
591 ("subparagraph" . 6)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
592 ("subsubparagraph" . 7)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
593 ("addchap" . -1) ; KOMA-Script
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
594 ("addsec" . -2) ; KOMA-Script
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
595 ;;; ("minisec" . -7) ; KOMA-Script
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
596 )
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
597 "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
598 The car of each cons cell is the name of the section macro. The cdr is a
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
599 number indicating its level. A negative level means the same as the
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
600 positive value, but the section will never get a number."
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
601 :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
602 :set 'reftex-set-dirty
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
603 :type '(repeat
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
604 (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
605 (number :tag "level " 0))))
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
606
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
607 (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
608 '((caption . "\\\\\\(rot\\)?caption\\*?[[{]")
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
609 (item . "\\\\item\\(\\[[^]]*\\]\\)?")
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
610 (eqnarray-like . "\\\\begin{%s}\\|\\\\\\\\")
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
611 (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
612 "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
613 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
614 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
615 or macro."
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
616 :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
617 :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
618
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
619 ;; Label insertion
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 (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
622 "Options on how to create new labels."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
623 :group 'reftex-label-support)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
624
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
625 (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
626 "Flags governing label insertion. First flag DERIVE, second flag PROMPT.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
627
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
628 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
629 A section label for example will be derived from the section heading.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
630 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
631 specifications given in `reftex-derive-label-parameters'.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
632 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
633 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
634 unique number, like `eq:23'.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
635
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
636 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
637 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
638 context. When PROMPT is nil, the default label will be inserted without
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
639 query.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
640
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
641 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
642 table describing all four possibilities:
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
643
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
644 DERIVE PROMPT ACTION
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
645 -------------------------------------------------------------------------
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
646 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
647 nil t Prompt for label.
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
648 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
649 t t Derive a label from context and prompt for confirmation.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
650
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
651 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
652 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
653 like character classes.
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
654 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
655 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
656 (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
657 without confirmation for everything else.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
658 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
659 e (equation), n (footnote), plus any definitions in `reftex-label-alist'."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
660 :group 'reftex-making-and-inserting-labels
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
661 :type '(list (choice :tag "Derive label from context"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
662 (const :tag "always" t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
663 (const :tag "never" nil)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
664 (string :tag "selected label types" ""))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665 (choice :tag "Prompt for label string "
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666 :entry-format " %b %v"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
667 (const :tag "always" t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
668 (const :tag "never" nil)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
669 (string :tag "selected label types" ""))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
671 (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
672 "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
673 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
674 :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
675 :type 'symbol)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
676
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
677 (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
678 "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
679 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
680 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
681 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
682 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
683 :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
684 :type 'symbol)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
685
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
686 (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
687 ("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
688 "Parameters for converting a string into a label.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
689 NWORDS Number of words to use.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
690 MAXCHAR Maximum number of characters in a label string.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
691 ILLEGAL nil: Throw away any words containing characters illegal in labels.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
692 t: Throw away only the illegal characters, not the whole word.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
693 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
694 t: Always abbreviate words (see `reftex-abbrev-parameters').
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
695 not t and not nil: Abbreviate words if necessary to shorten
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
696 label string below MAXCHAR.
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
697 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
698 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
699 DOWNCASE t: Downcase words before using them."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
700 :group 'reftex-making-and-inserting-labels
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
701 :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
702 (integer :tag "Maximum label length " 20)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
703 (choice :tag "Illegal characters in words"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
704 (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
705 (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
706 (choice :tag "Abbreviate words "
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
707 (const :tag "never" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
708 (const :tag "always" t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
709 (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
710 (string :tag "Separator between words " "-")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
711 (repeat :tag "Ignore words"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
712 :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
713 (string :tag ""))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
714 (option (boolean :tag "Downcase words "))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
715
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
716 (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
717 "Regexp matching characters not legal in labels."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
718 :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
719 :type '(regexp :tag "Regular Expression"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
720
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
721 (defcustom reftex-abbrev-parameters '(4 2 "^aeiou" "aeiou")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
722 "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
723 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
724 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
725 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
726 AFTER Character class after abbrev point in word."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
727 :group 'reftex-making-and-inserting-labels
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
728 :type '(list
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
729 (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
730 (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
731 (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
732 (string :tag "cut after char class " "aeiou")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
733
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
734 (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
735 "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
736 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
737 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
738 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
739 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
740 :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
741 :type 'function)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
742
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
743 ;; Label referencing
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
744
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
745 (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
746 "Options on how to reference labels."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
747 :group 'reftex-label-support)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
748
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
749 (eval-and-compile
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
750 (defconst reftex-tmp
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
751 '((const :tag "on" t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
752 (const :tag "off" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
753 (string :tag "Selected label types"))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
754
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
755 (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
756 "List of flags governing the label menu makeup.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
757 The flags are:
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
758
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
759 TABLE-OF-CONTENTS Show the labels embedded in a table of context.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
760 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
761 COUNTERS Show counters. This just numbers the labels in the menu.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
762 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
763 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
764 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
765 MATCH-IN-TOC Obsolete flag.
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
766 SHOW FILES Show begin and end of included files.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
767
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
768 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
769 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
770 like character classes in regular expressions. Thus, setting one of the
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
771 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
772 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
773 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
774 e (equation), n (footnote), plus any definitions in `reftex-label-alist'.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
775
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
776 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
777 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
778 get one interactively during selection from the label menu."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
779 :group 'reftex-referencing-labels
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
780 :type
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
781 `(list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
782 (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
783 (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
784 (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
785 (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
786 (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
787 (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
788 (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
789 (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
790
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
791 (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
792 "*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
793 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
794 `\\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
795 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
796 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
797 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
798 :group 'reftex-referencing-labels
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
799 :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
800
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
801 (defcustom reftex-level-indent 2
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
802 "*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
803 :group 'reftex-referencing-labels
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
804 :type 'integer)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
805
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
806 (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
807 "*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
808 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
809 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
810 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
811 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
812 :group 'reftex-referencing-labels
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
813 :type 'boolean)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
814
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
815 (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
816 "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
817 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
818 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
819 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
820 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
821 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
822 :group 'reftex-referencing-labels
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
823 :type 'function)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
824
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
825 (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
826 "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
827 :group 'reftex-referencing-labels
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
828 :type 'hook)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
829
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
830 ;; BibteX citation configuration ----------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
831
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
832 (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
833 "Support for referencing bibliographic data with BibTeX."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
834 :group 'reftex)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
835
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
836 (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
837 (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
838 "*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
839 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
840 Intended for files which contain only `@string' macro definitions and the
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
841 like, which are ignored by RefTeX anyway."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
842 :group 'reftex-citation-support
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
843 :set 'reftex-set-dirty
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
844 :type '(repeat (regexp)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
845
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
846 (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
847 "*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
848 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
849 `\bibliography{..}' statement nor a `thebibliography' environment,
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
850 RefTeX will scan these files instead. Intended for using `reftex-citation'
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
851 in non-LaTeX files. The files will be searched along the BIBINPUTS or TEXBIB
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
852 path."
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
853 :group 'reftex-citation-support
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
854 :type '(repeat (file)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
855
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
856 (defcustom reftex-sort-bibtex-matches 'reverse-year
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
857 "*Sorting of the entries found in BibTeX databases by reftex-citation.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
858 Possible values:
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
859 nil Do not sort entries.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
860 'author Sort entries by author name.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
861 'year Sort entries by increasing year.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
862 'reverse-year Sort entries by decreasing year."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
863 :group 'reftex-citation-support
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
864 :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
865 (const :tag "by author" author)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
866 (const :tag "by year" year)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
867 (const :tag "by year, reversed" reverse-year)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
868
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
869 (defcustom reftex-cite-format 'default
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
870 "*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
871 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
872 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
873 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
874
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
875 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
876 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
877
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
878 %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
879 %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
880 %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
881 %A First author name only.
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
882 %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
883
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
884 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
885 %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
886 %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
887 %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
888 %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
889 %v volume %y year
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
890 %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
891
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
892 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
893 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
894
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
895 %< 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
896 string has been formatted.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
897
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
898 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
899 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
900 environment, only %l is available.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
901
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
902 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
903 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
904 strings.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
905 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
906 `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
907 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
908 (setq reftex-cite-format 'natbib)"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
909 :group 'reftex-citation-support
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
910 :type
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
911 `(choice
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
912 :format "%{%t%}: \n%[Value Menu%] %v"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
913 (radio :tag "Symbolic Builtins"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
914 :indent 4
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
915 :value default
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
916 ,@(mapcar
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
917 (function
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
918 (lambda (x)
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
919 (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
920 ": " (nth 1 x))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
921 (nth 0 x))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
922 reftex-cite-format-builtin))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
923 (string :tag "format string" "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
924 (repeat :tag "key-ed format strings"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
925 :value ((?\r . "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
926 (?t . "\\cite{%l}") (?p . "\\cite{%l}"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
927 (cons (character :tag "Key character" ?\r)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
928 (string :tag "Format string" "")))))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
929
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
930 (defcustom reftex-comment-citations nil
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
931 "*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
932 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
933 :group 'reftex-citation-support
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
934 :type 'boolean)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
935
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
936 (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
937 "%% %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
938 "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
939 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
940 :group 'reftex-citation-support
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
941 :type 'string)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
942
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
943 (defcustom reftex-cite-view-format
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
944 "%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
945 "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
946 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
947 possible percent escapes."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
948 :group 'reftex-citation-support
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
949 :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
950 :type 'string)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
951
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
952 (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
953 "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
954 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
955 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
956 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
957 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
958 :group 'reftex-citation-support
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
959 :type '(list
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
960 (string :tag "Separator for names ")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
961 (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
962 (string :tag "string used as et al. ")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
963
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
964 (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
965 "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
966 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
967 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
968 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
969 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
970 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
971 :group 'reftex-citation-support
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
972 :type 'function)
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
973
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
974 (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
975 "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
976 :group 'reftex-citation-support
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
977 :type 'hook)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
978
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
979 ;; Viewing Cross References and Citations
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
980 (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
981 "Displaying cross references and citations."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
982 :group 'reftex)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
983
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
984 (defcustom reftex-view-crossref-extra
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
985 '(("index\\|idx" "\\\\[a-zA-Z]*\\(index\\|idx\\)[a-zA-Z]*\\*?\\(\\[[^]]*\\]\\|{[^}]*}\\)*{\\(%s\\)}" 3))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
986 "Macros which can be used for the display of cross references.
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
987 This is used when `reftex-view-crossref' is called with point in an
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
988 argument of a macro. Note that crossref viewing for citations and
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
989 references (both ways) is hard-coded. This variable is only to
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
990 configure additional structures for which crossreference viewing
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
991 can be useful. Each entry has the structure
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
992
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
993 (MACRO-RE SEARCH-RE HIGHLIGHT).
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
994
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
995 MACRO-RE is matched against the macro. SEARCH-RE is the regexp used
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
996 to search for cross references. `%s' in this regexp is replaced with
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
997 with the macro argument at point. HIGHLIGHT is an integer indicating
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
998 which subgroup of the match should be highlighted."
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
999 :group 'reftex-viewing-cross-references-and-citations
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1000 :type '(repeat (group (regexp :tag "Macro Regexp ")
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1001 (string :tag "Search Regexp ")
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1002 (integer :tag "Highlight Group"))))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1003
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1004 (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
1005 "*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
1006 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
1007 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
1008 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
1009 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
1010 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
1011 used for the display.
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1012 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
1013 (Ref->Options->Crossref Viewing)."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1014 :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
1015 :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
1016 (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
1017 (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
1018
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1019 (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
1020 "*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
1021 :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
1022 :type 'number)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1023
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1024 (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
1025 "*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
1026 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
1027 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
1028 :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
1029 :type 'boolean)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1030
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1031 (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
1032 "*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
1033 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
1034 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
1035 :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
1036 :type 'boolean)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1037
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1038 (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
1039 "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
1040 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
1041 :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
1042 :group 'reftex-referencing-labels
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1043 :type 'hook)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1044
23344
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1045 ;; Finding Files --------------------------------------------------------
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1046
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1047 (defgroup reftex-finding-files nil
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1048 "Finding files on search paths."
23344
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1049 :group 'reftex)
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1050
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1051 (defcustom reftex-texpath-environment-variables '("TEXINPUTS")
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1052 "*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
1053 Several entries are possible.
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1054 - 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
1055 - 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
1056 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
1057 be `!kpsewhich -show-path=.tex'.
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1058 - 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
1059 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
1060 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
1061 See also `reftex-use-external-file-finders'."
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1062 :group 'reftex-finding-files
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1063 :set 'reftex-set-dirty
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1064 :type '(repeat (string :tag "Specification")))
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1065
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1066 (defcustom reftex-bibpath-environment-variables '("BIBINPUTS" "TEXBIB")
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1067 "*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
1068 Several entries are possible.
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1069 - 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
1070 - 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
1071 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
1072 be `!kpsewhich -show-path=.bib'.
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1073 - 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
1074 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
1075 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
1076 See also `reftex-use-external-file-finders'."
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1077 :group 'reftex-citation-support
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1078 :group 'reftex-finding-files
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1079 :set 'reftex-set-dirty
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1080 :type '(repeat (string :tag "Specification")))
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1081
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1082 (defcustom reftex-file-extensions '(("tex" . (".tex" ".ltx"))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1083 ("bib" . (".bib")))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1084 "*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
1085 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
1086
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1087 TYPE: File type like \"bib\" or \"tex\".
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1088 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
1089 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
1090
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1091 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
1092 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
1093 :group 'reftex-finding-files
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1094 :type '(repeat (cons (string :tag "File type")
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1095 (repeat (string :tag "Extension")))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1096
23344
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1097 (defcustom reftex-search-unrecursed-path-first t
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1098 "*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
1099 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
1100 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
1101 \"./\" 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
1102 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
1103 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
1104 in wrong sequence."
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1105 :group 'reftex-finding-files
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1106 :type 'boolean)
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1107
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1108 (defcustom reftex-use-external-file-finders nil
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1109 "*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
1110 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
1111 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
1112 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
1113 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
1114 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
1115 `reftex-bibpath-environment-variables' will be ignored."
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1116 :group 'reftex-finding-files
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1117 :type 'boolean)
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1118
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1119 (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
1120 ("bib" . "kpsewhich -format=.bib %f"))
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1121 "*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
1122 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
1123 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
1124 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
1125 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
1126 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
1127 :group 'reftex-finding-files
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1128 :type '(repeat (cons (string :tag "File type")
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1129 (string :tag "Program "))))
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
1130
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1131 ;; Tuning the parser ----------------------------------------------------
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1132
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1133 (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
1134 "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
1135 :group 'reftex)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1136
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1137 (defcustom reftex-keep-temporary-buffers 1
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1138 "*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
1139 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
1140 We distinguish files visited for
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1141 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
1142 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
1143 to display label context, etc.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1144 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
1145 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
1146
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1147 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
1148 t Keep everything.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1149 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
1150 for lookup.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1151
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1152 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
1153 slow but will happen only once).
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1154 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
1155 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
1156 :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
1157 :type '(choice
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1158 (const :tag "Throw away everything" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1159 (const :tag "Keep everything" t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1160 (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
1161
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1162 (defcustom reftex-initialize-temporary-buffers nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1163 "*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
1164 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
1165 visit a file.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1166 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
1167 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
1168 do a minimal initialization."
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1169 :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
1170 :type '(choice
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1171 (const :tag "Read files literally" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1172 (const :tag "Fully initialize buffers" t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1173 (repeat :tag "Hook functions" :value (nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1174 (function-item))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1175
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1176 (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
1177 "*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
1178 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
1179 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
1180 :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
1181 :type '(repeat (regexp)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1182
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1183 (defcustom reftex-enable-partial-scans nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1184 "*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
1185 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
1186 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
1187 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
1188 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
1189 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
1190 in menus."
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1191 :group 'reftex-optimizations-for-large-documents
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1192 :type 'boolean)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1193
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1194 (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
1195 "*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
1196 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
1197 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
1198 list."
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1199 :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
1200 :type 'boolean)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1201
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1202 (defcustom reftex-save-parse-info nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1203 "*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
1204 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
1205 information. When this variable is t,
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1206 - 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
1207 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
1208 - 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
1209 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
1210 :group 'reftex-optimizations-for-large-documents
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1211 :type 'boolean)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1212
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1213 (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
1214 "*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
1215 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
1216 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
1217 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
1218 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
1219 `reftex-auto-update-selection-buffers'."
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1220 :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
1221 :group 'reftex-referencing-labels
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1222 :type 'boolean)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1223
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1224 (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
1225 "*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
1226 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
1227 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
1228 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
1229 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
1230 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
1231 `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
1232 :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
1233 :group 'reftex-referencing-labels
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1234 :type 'boolean)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1235
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1236 ;; Fontification and Faces ----------------------------------------------
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1237
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1238 (defgroup reftex-fontification-configurations nil
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1239 "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
1240 :group 'reftex)
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-use-fonts t
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1243 "*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
1244 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
1245 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
1246 :group 'reftex-fontification-configurations
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1247 :type 'boolean)
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1248
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1249 (defcustom reftex-refontify-context 1
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1250 "*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
1251 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
1252 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
1253
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1254 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
1255 nil Never refontify.
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1256 t Always refontify.
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1257 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
1258 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
1259 :group 'reftex-fontification-configurations
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1260 :group 'reftex-referencing-labels
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1261 :type '(choice
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1262 (const :tag "Never" nil)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1263 (const :tag "Always" t)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1264 (const :tag "When necessary" 1)))
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1265
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1266 (defcustom reftex-highlight-selection 'cursor
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1267 "*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
1268 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
1269 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
1270 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
1271 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
1272 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
1273
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1274 nil No highlighting.
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1275 cursor Highlighting is cursor driven.
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1276 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
1277 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
1278
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1279 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
1280 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
1281 :group 'reftex-fontification-configurations
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1282 :type '(choice
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1283 (const :tag "Never" nil)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1284 (const :tag "Cursor driven" cursor)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1285 (const :tag "Mouse driven" mouse)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1286 (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
1287
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1288 (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
1289 "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
1290 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
1291 :group 'reftex-fontification-configurations
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1292 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1293 (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
1294 "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
1295 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
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-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
1299 "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
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-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
1303 "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
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 (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
1307 "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
1308 :group 'reftex-fontification-configurations
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1309 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1310 (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
1311 "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
1312 :group 'reftex-fontification-configurations
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1313 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1314 (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
1315 "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
1316 :group 'reftex-fontification-configurations
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1317 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1318 (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
1319 "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
1320 :group 'reftex-fontification-configurations
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1321 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1322 (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
1323 "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
1324 :group 'reftex-fontification-configurations
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1325 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1326 (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
1327 "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
1328 :group 'reftex-fontification-configurations
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1329 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1330
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1331 (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
1332 "X-Symbol specific hook.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1333 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
1334 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
1335 :group 'reftex-fontification-configurations
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1336 :type 'hook)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1337
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1338 ;; Miscellaneous configurations -----------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1339
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1340 (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
1341 "Collection of further configurations."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1342 :group 'reftex)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1343
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1344 (defcustom reftex-extra-bindings nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1345 "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
1346 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
1347 :group 'reftex-miscellaneous-configurations
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1348 :type 'boolean)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1349
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1350 (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
1351 "*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
1352 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
1353 RefTeX will
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1354
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1355 - 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
1356 - 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
1357 - 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
1358 - 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
1359
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1360 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
1361 plug-ins on or off, respectively.
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1362 \\<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
1363 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
1364 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
1365 with \\[TeX-insert-macro].
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1366 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
1367 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
1368 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
1369 :group 'reftex-miscellaneous-configurations
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1370 :group 'LaTeX
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1371 :type '(choice
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1372 (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
1373 (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
1374 (list
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1375 :tag "Individual choice"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1376 :value (t t t t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1377 (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
1378 (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
1379 (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
1380 (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
1381 )))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1382
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1383 (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
1384 "*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
1385 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
1386 construct: \\bbb [xxx] {aaa}."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1387 :group 'texmathp
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1388 :type 'boolean)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1389
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1390
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1391 (defcustom reftex-load-hook nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1392 "Hook which is being run when loading reftex.el."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1393 :group 'reftex-miscellaneous-configurations
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1394 :type 'hook)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1395
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1396 (defcustom reftex-mode-hook nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1397 "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
1398 :group 'reftex-miscellaneous-configurations
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1399 :type 'hook)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1400
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1401 ;;; =========================================================================
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 ;;; Define the formal stuff for a minor mode named RefTeX.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1404 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1405
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1406 (defconst reftex-version "RefTeX version 3.43"
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
1407 "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
1408
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1409 (defvar reftex-mode nil
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1410 "Determines if RefTeX mode is active.")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1411 (make-variable-buffer-local 'reftex-mode)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1412
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1413 (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
1414 "Keymap for RefTeX mode.")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1415
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1416 (defvar reftex-mode-menu nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1417
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1418 ;;;###autoload
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1419 (defun turn-on-reftex ()
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1420 "Turn on RefTeX mode."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1421 (reftex-mode t))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1422
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1423 ;;;###autoload
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1424 (defun reftex-mode (&optional arg)
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
1425 "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
1426
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1427 Labels can be created with `\\[reftex-label]' and referenced with `\\[reftex-reference]'.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1428 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
1429 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
1430 \\ref macro.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1431
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1432 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
1433 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
1434 database. The selected citation is inserted as a \\cite macro.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1435
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1436 A Table of Contents of the entire (multifile) document with browsing
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1437 capabilities is available with `\\[reftex-toc]'.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1438
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1439 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
1440 pressing `?' to any prompt mentioning this feature.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1441
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1442 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
1443 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
1444
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1445 \\{reftex-mode-map}
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1446 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
1447 on the menu bar.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1448
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1449 ------------------------------------------------------------------------------"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1450
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1451 (interactive "P")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1452 (setq reftex-mode (not (or (and (null arg) reftex-mode)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1453 (<= (prefix-numeric-value arg) 0))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1454
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1455 (if reftex-mode
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1456 (progn
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1457 ;; Mode was turned on
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1458 (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
1459 (and reftex-plug-into-AUCTeX
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1460 (reftex-plug-into-AUCTeX))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1461 (unless (get 'reftex-auto-view-crossref 'initialized)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1462 (and reftex-auto-view-crossref
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1463 (reftex-toggle-auto-view-crossref))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1464 (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
1465 (run-hooks 'reftex-mode-hook))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1466 ;; Mode was turned off
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1467 (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
1468
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1469 (if (fboundp 'add-minor-mode)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1470 ;; 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
1471 (progn
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1472 (put 'reftex-mode :included '(memq major-mode '(latex-mode tex-mode)))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1473 (put 'reftex-mode :menu-tag "RefTeX Mode")
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1474 (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
1475 ;; The standard way
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1476 (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
1477 (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
1478 (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
1479 (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
1480
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1481 ;;; =========================================================================
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1482 ;;;
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1483 ;;; 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
1484 (defvar TeX-master)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1485 (defvar LaTeX-section-hook)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1486 (defvar LaTeX-label-function)
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1487 (defvar tex-main-file)
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1488 (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
1489 (defvar font-lock-mode)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1490 (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
1491 (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
1492
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1493 ;;; =========================================================================
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1494 ;;;
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1495 ;;; Multibuffer Variables
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1496 ;;;
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1497 ;;; Technical notes: These work as follows: We keep just one list
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1498 ;;; 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
1499 ;;; `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
1500 ;;; 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
1501 ;;; document. Each buffer has local variables which point to these symbols.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1502
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1503 ;; List of variables which handle the multifile stuff.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1504 ;; This list is used to tie, untie, and reset these symbols.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1505 (defconst reftex-multifile-symbols
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1506 '(reftex-docstruct-symbol))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1507
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1508 ;; Alist connecting master file names with the corresponding lisp symbols.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1509 (defvar reftex-master-index-list nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1510
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1511 ;; Last index used for a master file.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1512 (defvar reftex-multifile-index 0)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1513
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1514 ;; 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
1515 (defvar reftex-docstruct-symbol nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1516 (make-variable-buffer-local 'reftex-docstruct-symbol)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1517
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1518 (defun reftex-next-multifile-index ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1519 ;; 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
1520 (incf reftex-multifile-index))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1521
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1522 (defun reftex-tie-multifile-symbols ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1523 ;; Tie the buffer-local symbols to globals connected with the master file.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1524 ;; 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
1525
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1526 (let* ((master (file-truename (reftex-TeX-master-file)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1527 (index (assoc master reftex-master-index-list))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1528 (symlist reftex-multifile-symbols)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1529 symbol symname newflag)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1530 ;; Find the correct index.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1531 (if index
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1532 ;; symbols do exist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1533 (setq index (cdr index))
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1534 ;; Get a new index and add info to the alist.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1535 (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
1536 newflag t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1537 (push (cons master index) reftex-master-index-list))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1538
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1539 ;; Get/create symbols and tie them.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1540 (while symlist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1541 (setq symbol (car symlist)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1542 symlist (cdr symlist)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1543 symname (symbol-name symbol))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1544 (set symbol (intern (concat symname "-" (int-to-string index))))
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1545 (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
1546 ;; Initialize if new symbols.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1547 (if newflag (set (symbol-value symbol) nil)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1548
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1549 ;; 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
1550 (not newflag)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1551
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1552 (defun reftex-untie-multifile-symbols ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1553 ;; Remove ties from multifile symbols, so that next use makes new ones.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1554 (let ((symlist reftex-multifile-symbols)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1555 (symbol nil))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1556 (while symlist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1557 (setq symbol (car symlist)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1558 symlist (cdr symlist))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1559 (set symbol nil))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1560
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1561 (defun reftex-TeX-master-file ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1562 ;; Return the name of the master file associated with the current buffer.
24389
8de7eb6fef39 Comment fix.
Karl Heuer <kwzh@gnu.org>
parents: 23995
diff changeset
1563 ;; When AUCTeX is loaded, we will use its more sophisticated method.
18219
aaeaae005e98 Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents: 18123
diff changeset
1564 ;; 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
1565 ;; variable tex-main-file.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1566 (let
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1567 ((master
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1568 (cond
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1569 ((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
1570 (condition-case nil
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1571 (TeX-master-file t)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1572 (error (buffer-file-name))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1573 ((boundp 'TeX-master) ; The variable is defined - lets use it.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1574 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1575 ((eq TeX-master t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1576 (buffer-file-name))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1577 ((eq TeX-master 'shared)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1578 (setq TeX-master (read-file-name "Master file: "
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1579 nil nil t nil)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1580 (TeX-master)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1581 (t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1582 (setq TeX-master (read-file-name "Master file: "
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1583 nil nil t nil)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1584 ((boundp 'tex-main-file)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1585 ;; This is the variable from the default TeX modes.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1586 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1587 ((stringp tex-main-file)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1588 ;; ok, this must be it
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1589 tex-main-file)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1590 (t
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1591 ;; In this case, the buffer is its own master.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1592 (buffer-file-name))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1593 (t
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1594 ;; Know nothing about master file. Assume this is a master file.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1595 (buffer-file-name)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1596 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1597 ((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
1598 (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
1599 ((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
1600 (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
1601 ;; 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
1602 (setq master (concat master ".tex")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1603 ((or (file-exists-p master)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1604 (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
1605 ;; 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
1606 )
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1607 (t
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1608 ;; Use buffer file name.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1609 (buffer-file-name)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1610 (expand-file-name master)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1611
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1612 ;;; =========================================================================
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1613 ;;;
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1614 ;;; 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
1615
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1616 ;; 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
1617
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1618 ;; Prompt used for label type queries directed to the user.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1619 (defconst reftex-type-query-prompt nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1620
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1621 ;; Help string for label type queries.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1622 (defconst reftex-type-query-help nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1623
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1624 ;; Alist relating label type to reference format.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1625 (defconst reftex-typekey-to-format-alist nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1626
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1627 ;; Alist relating label type to label affix.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1628 (defconst reftex-typekey-to-prefix-alist nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1629
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1630 ;; Alist relating environments or macros to label type and context regexp.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1631 (defconst reftex-env-or-mac-alist nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1632
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1633 ;; List of macros carrying a label.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1634 (defconst reftex-label-mac-list nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1635
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1636 ;; List of environments carrying a label.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1637 (defconst reftex-label-env-list nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1638
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1639 ;; List of all typekey letters in use.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1640 (defconst reftex-typekey-list nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1641
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1642 ;; Alist relating magic words to a label type.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1643 (defconst reftex-words-to-typekey-alist nil)
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 ;; The last list-of-labels entry used in a reference.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1646 (defvar reftex-last-used-reference (list nil nil nil 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 ;; 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
1649 (defconst reftex-no-follow-message
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1650 "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
1651 (defconst reftex-no-info-message
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1652 "%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
1653
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1654 ;; Global variables used for communication between functions.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1655 (defvar reftex-default-context-position nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1656 (defvar reftex-location-start nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1657 (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
1658 (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
1659 (defvar reftex-active-toc nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1660 (defvar reftex-tex-path nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1661 (defvar reftex-bib-path nil)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
1662 (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
1663 (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
1664 (defvar reftex-prefix nil)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1665 (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
1666 (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
1667 (defvar reftex-callback-fwd t)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1668
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1669 ;; List of buffers created temporarily for lookup, which should be killed.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1670 (defvar reftex-buffers-to-kill nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1671
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1672 ;; Regexp to find anything.
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
1673 (defvar reftex-section-regexp nil)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1674 (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
1675 (defvar reftex-everything-regexp nil)
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1676 (defvar reftex-find-citation-regexp-format
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1677 "\\\\[a-zA-Z]*cite[*a-zA-Z]*\\*?\\(\\[[^]]*\\]\\|{[^}]*}\\)*{\\([^}]*,\\)?\\(%s\\)[},]")
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1678 (defvar reftex-find-reference-format
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1679 "\\\\\\(ref[a-zA-Z]*\\|[a-zA-Z]*ref\\)\\*?\\(\\[[^]]*\\]\\|{[^}]*}\\)*{\\(%s\\)}")
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1680 (defvar reftex-macros-with-labels nil)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1681 (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
1682 (defvar reftex-find-label-regexp-format2 nil)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1683
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1684 ;;; The parser functions -----------------------------------------------------
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1685
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1686 (defvar reftex-memory nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1687 "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
1688
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1689 (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
1690 "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
1691 ;; 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
1692 ;; 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
1693 ;; 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
1694 ;; 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
1695
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1696 ;; 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
1697 (if (eq reftex-docstruct-symbol nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1698 ;; 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
1699 (reftex-tie-multifile-symbols))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1700
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1701 (reftex-ensure-compiled-variables)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1702
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1703 (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
1704 (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
1705 ;; 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
1706 (save-excursion
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1707 (reftex-erase-buffer "*toc*")
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1708 (reftex-erase-all-selection-buffers)))
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 (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
1711 (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
1712 reftex-save-parse-info)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1713 ;; 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
1714 (reftex-access-parse-file 'read))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1715
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1716 (cond
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1717 ((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
1718 ((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
1719 ;; Scan the whole document
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1720 (reftex-do-parse 1 file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1721 ((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
1722 ;; 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
1723 (reftex-do-parse rescan file))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1724
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1725 (defun reftex-parse-one ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1726 "Re-parse this file."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1727 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1728 (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
1729 (reftex-access-scan-info '(4))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1730
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1731 (defun reftex-parse-all ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1732 "Re-parse entire document."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1733 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1734 (reftex-access-scan-info '(16)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1735
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1736 (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
1737 "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
1738
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1739 ;; Normalize the rescan argument
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1740 (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
1741 ((eq rescan 1) 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1742 ((equal rescan '(4)) t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1743 ((equal rescan '(16)) 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1744 (t 1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1745
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1746 ;; Partial scans only when allowed
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1747 (unless reftex-enable-partial-scans
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1748 (setq rescan 1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1749
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1750 ;; Do the scanning.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1751
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1752 (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
1753 (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
1754 (true-master (file-truename master))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1755 (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
1756 (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
1757 (true-file (file-truename file))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1758 (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
1759 from-file appendix docstruct tmp)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1760
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1761 ;; 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
1762 (when (and (eq rescan t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1763 (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
1764 (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
1765 ;; 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
1766 (setq rescan 1))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1767 (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
1768 ;; 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
1769 (setq rescan 1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1770
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1771 ;; From which file do we start?
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1772 (setq from-file
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1773 (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
1774 ((eq rescan 1) master)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1775 (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
1776
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1777 ;; 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
1778 (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
1779 '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
1780 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
1781 '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
1782
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1783 (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
1784
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1785 (if (eq rescan 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1786 (message "Scanning entire document...")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1787 (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
1788
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1789 (save-window-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1790 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1791 (unwind-protect
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1792 (setq docstruct
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1793 (reftex-parse-from-file
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1794 from-file docstruct master-dir))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1795 (reftex-kill-temporary-buffers))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1796
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1797 (message "Scanning document... done")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1798
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1799 ;; Turn the list around.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1800 (setq docstruct (nreverse docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1801
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1802 ;; Set or insert
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1803 (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
1804 old-list docstruct (eq rescan 1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1805
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1806 ;; Add all missing information
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1807 (unless (assq 'label-numbers docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1808 (push (cons 'label-numbers nil) docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1809 (unless (assq 'master-dir docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1810 (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
1811 (unless (assq 'bibview-cache docstruct)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1812 (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
1813 (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
1814 (bof2 (assq 'bof (cdr bof1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1815 (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
1816 (entry (or (assq 'is-multi docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1817 (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
1818 (setcdr entry (cons is-multi nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1819 (unless (assq 'xr docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1820 (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
1821 (alist (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1822 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1823 (lambda (x)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1824 (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
1825 master-dir))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1826 (cons (nth 1 x) tmp)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1827 (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
1828 (nth 2 x))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1829 nil)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1830 allxr))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1831 (alist (delq nil alist))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1832 (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
1833 (regexp (if allprefix
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1834 (concat "\\`\\("
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1835 (mapconcat 'identity allprefix "\\|")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1836 "\\)")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1837 "\\\\\\\\\\\\"))) ; this will never match
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1838 (push (list 'xr alist regexp) docstruct)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1839
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1840 (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
1841 (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
1842
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1843 (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
1844 ;; 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
1845 (let ((regexp reftex-everything-regexp)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1846 (bound 0)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1847 file-found tmp include-file
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1848 (level 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1849 (highest-level 100)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1850 toc-entry next-buf buf)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1851
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1852 (catch 'exit
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
1853 (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
1854 (if (and (not file-found)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1855 (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
1856 (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
1857
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1858 (unless file-found
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1859 (push (list 'file-error file) docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1860 (throw 'exit nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1861
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1862 (save-excursion
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 (message "Scanning file %s" file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1865 (set-buffer
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1866 (setq next-buf
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1867 (reftex-get-file-buffer-force
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1868 file-found
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1869 (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
1870
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1871 ;; Begin of file mark
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1872 (setq file (buffer-file-name))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1873 (push (list 'bof file) docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1874
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1875 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1876 (save-restriction
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1877 (widen)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1878 (goto-char 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1879
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1880 (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
1881
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1882 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1883
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1884 ((match-end 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1885 ;; It is a label
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1886 (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
1887 docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1888
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1889 ((match-end 3)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1890 ;; It is a section
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1891 (setq bound (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1892
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1893 ;; Insert in List
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1894 (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
1895 (setq level (nth 5 toc-entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1896 (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
1897 (if (= level highest-level)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1898 (message
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1899 "Scanning %s %s ..."
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1900 (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
1901 (nth 6 toc-entry)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1902
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1903 (push toc-entry docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1904 (setq reftex-active-toc toc-entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1905
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1906 ((match-end 7)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1907 ;; 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
1908 (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
1909 ;; 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
1910 (unless (delq nil (mapcar
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1911 (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
1912 reftex-no-include-regexps))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1913 ;; Parse it
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1914 (setq docstruct
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1915 (reftex-parse-from-file
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1916 include-file
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1917 docstruct master-dir))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1918
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1919 ((match-end 9)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1920 ;; Appendix starts here
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1921 (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
1922 (push (cons 'appendix t) docstruct))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1923
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1924 ((match-end 10)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1925 ;; A macro with label
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1926 (save-excursion
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1927 (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
1928 (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
1929 (save-match-data
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1930 (reftex-no-props
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1931 (reftex-nth-arg-wrapper
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1932 mac)))))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1933 (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
1934 (entry (progn (if typekey
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1935 ;; A typing macro
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1936 (goto-char (match-end 0))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1937 ;; A newtral macro
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1938 (goto-char (match-end 10))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1939 (reftex-move-over-touching-args))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1940 (reftex-label-info
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
1941 label file bound nil nil))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1942 (push entry docstruct))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1943 (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
1944 )
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1945
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1946 ;; Find bibliography statement
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1947 (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
1948 (push (cons 'bib tmp) docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1949
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1950 (goto-char 1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1951 (when (re-search-forward
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1952 "\\(\\`\\|[\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
1953 (push (cons 'thebib file) docstruct))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1954
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1955 ;; Find external document specifications
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1956 (goto-char 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1957 (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
1958 (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
1959 (reftex-match-string 3))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1960 docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1961
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1962 ;; End of file mark
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1963 (push (list 'eof file) docstruct))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1964
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1965 ;; Kill the scanned buffer
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1966 (reftex-kill-temporary-buffers next-buf))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1967
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1968 ;; Return the list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1969 docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1970
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1971 (defun reftex-locate-bibliography-files (master-dir &optional files)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1972 ;; Scan buffer for bibliography macro and return file list.
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1973
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1974 (unless files
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1975 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1976 (goto-char (point-min))
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1977 (if (re-search-forward
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1978 "\\(\\`\\|[\n\r]\\)[ \t]*\\\\bibliography{[ \t]*\\([^}]+\\)" nil t)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1979 (setq files
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1980 (split-string (reftex-match-string 2)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1981 "[ \t\n\r]*,[ \t\n\r]*")))))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1982 (when files
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1983 (setq files
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1984 (mapcar
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1985 (lambda (x)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1986 (if (or (member x reftex-bibfile-ignore-list)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1987 (delq nil (mapcar (lambda (re) (string-match re x))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1988 reftex-bibfile-ignore-regexps)))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1989 ;; excluded file
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1990 nil
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1991 ;; find the file
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1992 (reftex-locate-file x "bib" master-dir)))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1993 files))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1994 (delq nil files)))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1996 (defun reftex-default-bibliography ()
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1997 ;; Return the expanded value of `reftex-default-bibliography'.
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1998 ;; The expanded value is cached.
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
1999 (unless (eq (get 'reftex-default-bibliography :reftex-raw)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2000 reftex-default-bibliography)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2001 (put 'reftex-default-bibliography :reftex-expanded
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2002 (reftex-locate-bibliography-files
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2003 default-directory reftex-default-bibliography))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2004 (put 'reftex-default-bibliography :reftex-raw
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2005 reftex-default-bibliography))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2006 (get 'reftex-default-bibliography :reftex-expanded))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2007
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2008 (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
2009 ;; 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
2010 ;; 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
2011 ;; 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
2012 ;; 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
2013
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2014 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2015 (entirely
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2016 (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
2017 insert)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2018 (t (let* ((new old)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2019 (file (nth 1 (car insert)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2020 (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
2021 (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
2022 n)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2023 (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
2024 (error "Cannot splice")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2025 ;; Splice
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2026 (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
2027 (length eof-list)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2028 (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
2029 (setcdr (nthcdr n new) (cdr insert))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2030 (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
2031 new))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2032
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2033 (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
2034 ;; 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
2035 (while (and list (> (decf n) -1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2036 (and (eq (car (car list)) 'toc)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2037 (markerp (nth 4 (car list)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2038 (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
2039 (pop list)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2040
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2041 (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
2042 "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
2043 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
2044 (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
2045 (docstruct-symbol reftex-docstruct-symbol)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2046 (master (reftex-TeX-master-file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2047 (enable-local-variables nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2048 (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
2049 (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
2050 (concat master ".rel"))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2051 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2052 ((eq action 'readable)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2053 (file-readable-p file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2054 ((eq action 'restore)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2055 (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
2056 (if (eq reftex-docstruct-symbol nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2057 ;; 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
2058 (reftex-tie-multifile-symbols))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2059 (if (file-exists-p file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2060 ;; 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
2061 (condition-case nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2062 (progn (load-file file) t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2063 (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
2064 (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
2065 ;; 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
2066 (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
2067 ((eq action 'read)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2068 (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
2069 (if (file-exists-p file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2070 ;; 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
2071 (condition-case nil
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2072 (progn
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2073 (load-file file)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2074 (reftex-check-parse-consistency)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2075 t)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2076 (error (message "Error while restoring file %s" file)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2077 (set reftex-docstruct-symbol nil)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2078 nil))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2079 ;; 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
2080 nil))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2081 ((eq action 'kill)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2082 ;; Remove the file
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2083 (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
2084 (message "Unlinking file %s" file)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2085 (delete-file file)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2086 (t
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2087 (put docstruct-symbol 'modified nil)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2088 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2089 (if (file-writable-p file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2090 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2091 (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
2092 (find-file file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2093 (erase-buffer)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2094 (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
2095 (insert (format ";; File: %s\n" master))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2096 (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
2097 (user-login-name) (user-full-name)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2098 (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
2099 (let ((standard-output (current-buffer)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2100 (mapcar
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2101 (function
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2102 (lambda (x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2103 (cond ((eq (car x) 'toc)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2104 ;; 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
2105 ;; 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
2106 (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
2107 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
2108 (or (and (markerp (nth 4 x))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2109 (marker-position (nth 4 x)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2110 (nth 8 x)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2111 (t (print x)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2112 list))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2113 (insert "))\n\n")
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2114 (save-buffer 0)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2115 (kill-buffer (current-buffer)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2116 (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
2117 t))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2118
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2119 (defun reftex-check-parse-consistency ()
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2120 ;; Check if parse file is consistent, throw an error if not.
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2121
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2122 ;; Check if the master is the same: when moving a document, this will see it.
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2123 (let* ((real-master (reftex-TeX-master-file))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2124 (parsed-master
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2125 (nth 1 (assq 'bof (symbol-value reftex-docstruct-symbol)))))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2126 (unless (string= (file-truename real-master) (file-truename parsed-master))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2127 (message "Master file name in load file is different: %s versus %s"
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2128 parsed-master real-master)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2129 (error "Master file name error")))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2130
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2131 ;; Check for the existence of all document files
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2132 ;;; (let* ((all (symbol-value reftex-docstruct-symbol)))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2133 ;;; (while all
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2134 ;;; (when (and (eq (car (car all)) 'bof)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2135 ;;; (not (file-regular-p (nth 1 (car all)))))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2136 ;;; (message "File %s in saved parse info not avalable" (cdr (car all)))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2137 ;;; (error "File not found"))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2138 ;;; (setq all (cdr all))))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2139 )
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2140
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2141 (defun reftex-kill-buffer-hook ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2142 "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
2143 ;; 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
2144 ;; 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
2145 ;; 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
2146 (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
2147 (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
2148 (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
2149 (symbol-value reftex-docstruct-symbol)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2150 (get reftex-docstruct-symbol 'modified))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2151 ;; Write the file.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2152 (condition-case nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2153 (reftex-access-parse-file 'write)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2154 (error nil))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2155
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2156 (defun reftex-kill-emacs-hook ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2157 "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
2158 ;; 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
2159 (save-excursion
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2160 (mapcar (lambda (buf)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2161 (set-buffer buf)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2162 (reftex-kill-buffer-hook))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2163 (buffer-list))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2164
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2165 (defun reftex-section-info (file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2166 ;; 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
2167 ;; 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
2168 (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
2169 (macro (reftex-match-string 3))
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2170 (level (cdr (assoc macro reftex-section-levels-all)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2171 (star (= ?* (char-after (match-end 3))))
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2172 (unnumbered (or star (< level 0)))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2173 (level (abs level))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
2174 (section-number (reftex-section-number level unnumbered))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2175 (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
2176 (literal (buffer-substring-no-properties
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2177 (1- (match-beginning 3))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2178 (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
2179 ;; 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
2180 (text (reftex-nicify-text text1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2181
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2182 ;; Add section number and indentation
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2183 (setq text
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2184 (concat
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2185 (make-string (* reftex-level-indent level) ?\ )
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2186 (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
2187 (concat section-number " "))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2188 text))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2189 (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
2190 literal (marker-position marker))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2191
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2192 (defun reftex-label-info-update (cell)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2193 ;; Update information about just one label in a different file.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2194 ;; CELL contains the old info list
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2195 (let* ((label (nth 0 cell))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2196 (typekey (nth 1 cell))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2197 ;; (text (nth 2 cell))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2198 (file (nth 3 cell))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2199 (comment (nth 4 cell))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2200 (note (nth 5 cell))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2201 (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
2202 file (not (eq t reftex-keep-temporary-buffers)))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2203 (if (not buf)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2204 (list label typekey "" file comment "LOST LABEL. RESCAN TO FIX.")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2205 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2206 (set-buffer buf)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2207 (save-restriction
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2208 (widen)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2209 (goto-char 1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2210
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2211 (if (or (re-search-forward
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2212 (format reftex-find-label-regexp-format
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2213 (regexp-quote label)) nil t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2214 (re-search-forward
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2215 (format reftex-find-label-regexp-format2
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2216 (regexp-quote label)) nil t))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2217
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2218 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2219 (backward-char 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2220 (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
2221 (list label typekey "" file "LOST LABEL. RESCAN TO FIX.")))))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2222
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2223 (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
2224 ;; 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
2225 (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
2226 (typekey (nth 1 (assoc env-or-mac reftex-env-or-mac-alist)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2227 (file (or file (buffer-file-name)))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2228 (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
2229 (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
2230 derive))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2231 (in-comment (reftex-in-comment)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2232 (list label typekey text file in-comment)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2233
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2234 (defun reftex-in-comment ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2235 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2236 (skip-chars-backward "^%\n\r")
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2237 (eq (preceding-char) ?%)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2238
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2239 (defun reftex-short-context (env parse &optional bound derive)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2240 ;; 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
2241
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2242 (if (consp parse)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2243 (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
2244
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2245 (reftex-nicify-text
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2246
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2247 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2248
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2249 ((null parse)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2250 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2251 (reftex-context-substring)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2252
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2253 ((eq parse t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2254 (if (string= env "section")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2255 ;; special treatment for section labels
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2256 (save-excursion
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2257 (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
2258 (point-min) t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2259 (match-end 2))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2260 (progn
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2261 (goto-char (match-end 0))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2262 (reftex-context-substring))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2263 (if reftex-active-toc
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2264 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2265 (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
2266 (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
2267 "SECTION HEADING NOT FOUND")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2268 (save-excursion
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2269 (goto-char reftex-default-context-position)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2270 (unless (eq (string-to-char env) ?\\)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2271 (reftex-move-over-touching-args))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2272 (reftex-context-substring))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2273
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2274 ((stringp parse)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2275 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2276 (if (re-search-backward parse bound t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2277 (progn
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2278 (goto-char (match-end 0))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2279 (reftex-context-substring))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2280 "NO MATCH FOR CONTEXT REGEXP")))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2281
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2282 ((integerp parse)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2283 (or (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2284 (goto-char reftex-default-context-position)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2285 (reftex-nth-arg
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2286 parse
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2287 (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
2288 ""))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2289
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2290 ((fboundp parse)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
2291 ;; A hook function. Call it.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2292 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2293 (condition-case error-var
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2294 (funcall parse env)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2295 (error (format "HOOK ERROR: %s" (cdr error-var))))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2296 (t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2297 "ILLEGAL VALUE OF PARSE"))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2298
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2299 (defun reftex-nicify-text (text)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2300 ;; 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
2301 ;; 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
2302 (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
2303 (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
2304 ;; 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
2305 (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
2306 (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
2307 ;; 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
2308 (if (string-match "\\\\label{[^}]*}" text)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2309 (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
2310 ;; 4. remove leading garbage
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2311 (if (string-match "\\`[ }]+" text)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2312 (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
2313 ;; 5. limit length
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2314 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2315 ((> (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
2316 ((= (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
2317 (t text)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2318
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2319 (defun reftex-where-am-I ()
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2320 ;; 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
2321 ;; 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
2322 ;; exact (t) or approximate (nil).
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2323
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2324 (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
2325 (cnt 0) rtn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2326 found)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2327 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2328 (while (not rtn)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2329 (incf cnt)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2330 (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
2331 (setq rtn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2332 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2333 ((not found)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2334 ;; no match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2335 (or
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2336 (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
2337 (not (setq cnt 2))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2338 (assq 'bof docstruct) ;; for safety reasons
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2339 'corrupted))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2340 ((match-end 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2341 ;; Label
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2342 (assoc (reftex-match-string 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2343 (symbol-value reftex-docstruct-symbol)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2344 ((match-end 3)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2345 ;; Section
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2346 (goto-char (1- (match-beginning 3)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2347 (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
2348 docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2349 (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
2350 list)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2351 rtn1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2352 (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
2353 (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
2354 (string= (buffer-file-name)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2355 (nth 3 (car list))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2356 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2357 ((equal (point)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2358 (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
2359 (marker-position (nth 4 (car list))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2360 (nth 8 (car list))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2361 ;; 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
2362 (setq rtn1 (car list) list nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2363 ((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
2364 (nth 7 (car list))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2365 ;; Same title
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2366 (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
2367 (pop list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2368 rtn1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2369 ((match-end 7)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2370 ;; Input or include...
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2371 (car
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2372 (member (list 'eof (reftex-locate-file
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2373 (reftex-match-string 7) "tex"
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2374 (cdr (assq 'master-dir docstruct))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2375 docstruct)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2376 ((match-end 9)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2377 (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
2378 ((match-end 10)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2379 (save-excursion
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2380 (goto-char (match-end 10))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2381 (assoc (reftex-no-props
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2382 (reftex-nth-arg-wrapper
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2383 (reftex-match-string 10)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2384 (symbol-value reftex-docstruct-symbol))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2385 (t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2386 (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
2387 (cons rtn (eq cnt 1))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2388
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2389 (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
2390 "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
2391 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
2392
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2393 (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
2394 (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
2395 (p1 (or (cdr loc1) 0))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2396 (p2 (or (cdr loc2) 0)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2397
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2398 (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
2399 (if (>= p1 p2)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2400 (progn
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2401 (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
2402 (or (car loc1) "section"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2403 (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
2404 (or (car loc2) "section"))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2405
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2406 (defun reftex-parse-args (macro)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2407 ;; 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
2408 ;; optional argument indices.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2409 (if (string-match "[[{]\\*?[]}]" macro)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2410 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2411 (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
2412 (args (substring macro (match-beginning 0)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2413 opt-list nlabel (cnt 0))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2414 (while (string-match "\\`[[{]\\(\\*\\)?[]}]" args)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2415 (incf cnt)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2416 (when (eq ?\[ (string-to-char args))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2417 (push cnt opt-list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2418 (when (and (match-end 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2419 (not nlabel))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2420 (setq nlabel cnt))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2421 (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
2422 (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
2423 nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2424
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2425 (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
2426 ;; 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
2427 ;; 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
2428 ;; 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
2429 ;; in TeX.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2430 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2431 ;; Just to be quick:
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2432 ((memq (following-char) '(?\[ ?\{)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2433 ;; Do a search
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2434 ((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
2435 (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
2436 (goto-char (1- (match-end 0)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2437 t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2438 (t nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2439
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2440 (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
2441 ;; 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
2442 ;; 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
2443 ;; 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
2444 ;; in TeX.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2445 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2446 ;; Just to be quick:
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2447 ((memq (preceding-char) '(?\] ?\})))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2448 ;; Do a search
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2449 ((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
2450 (re-search-backward
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2451 "[]}][ \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
2452 (goto-char (1+ (match-beginning 0)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2453 t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2454 (t nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2455
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2456 (defun reftex-nth-arg-wrapper (key)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2457 (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
2458 (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
2459
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2460 (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
2461 ;; 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
2462 ;; 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
2463
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2464 ;; 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
2465 (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
2466
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2467 (if (= n 1000)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2468 ;; Special case: Skip all touching arguments
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2469 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2470 (reftex-move-over-touching-args)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2471 (reftex-context-substring))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2472
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2473 ;; Do the real thing.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2474 (let ((cnt 1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2475
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2476 (when (reftex-move-to-next-arg)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2477
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2478 (while (< cnt n)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2479 (while (and (member cnt opt-args)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2480 (eq (following-char) ?\{))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2481 (incf cnt))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2482 (when (< cnt n)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2483 (unless (and (condition-case nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2484 (or (forward-list 1) t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2485 (error nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2486 (reftex-move-to-next-arg)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2487 (incf cnt))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2488 (setq cnt 1000))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2489
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2490 (while (and (memq cnt opt-args)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2491 (eq (following-char) ?\{))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2492 (incf cnt)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2493 (if (and (= n cnt)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2494 (> (skip-chars-forward "{\\[") 0))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2495 (reftex-context-substring)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2496 nil))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2497
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2498 (defun reftex-move-over-touching-args ()
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2499 (condition-case nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2500 (while (memq (following-char) '(?\[ ?\{))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2501 (forward-list 1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2502 (error nil)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2503
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2504 (defun reftex-context-substring ()
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2505 ;; Return up to 150 chars from point
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2506 ;; When point is just after a { or [, limit string to matching parenthesis
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2507 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2508 ((or (= (preceding-char) ?\{)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2509 (= (preceding-char) ?\[))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2510 ;; 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
2511 (buffer-substring-no-properties
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2512 (point)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2513 (min (+ (point) 150)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2514 (point-max)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2515 (condition-case nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2516 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2517 (up-list 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2518 (1- (point)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2519 (error (point-max))))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2520 (t
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2521 ;; 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
2522 (buffer-substring-no-properties (point)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2523 (min (+ (point) 150) (point-max))))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2524
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2525 ;; 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
2526 (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
2527
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2528 (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
2529 ;; 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
2530 ;; in the toc entry.
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2531 (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
2532 (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
2533 (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
2534 (i depth) number-string)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2535 (while (>= i 0)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2536 (if (> i level)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2537 (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
2538 (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
2539 (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
2540 (aset reftex-section-numbers i
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2541 (- (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
2542 (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
2543 (pop numbers))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2544 (decf i)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2545 (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
2546
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2547 (defun reftex-section-number (&optional level star)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2548 ;; Return a string with the current section number.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2549 ;; 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
2550 (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
2551 (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
2552 (when level
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2553 (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
2554 (aset reftex-section-numbers
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2555 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
2556 (setq idx (1+ level))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2557 (when (not star)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2558 (while (<= idx depth)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2559 (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
2560 (incf idx))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2561 (setq idx 0)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2562 (while (<= idx depth)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2563 (setq n (aref reftex-section-numbers idx))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2564 (setq string (concat string (if (not (string= string "")) "." "")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2565 (int-to-string n)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2566 (incf idx))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2567 (save-match-data
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2568 (if (string-match "\\`\\([@0]\\.\\)+" string)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2569 (setq string (replace-match "" nil nil string)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2570 (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
2571 (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
2572 (if (and appendix
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2573 (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
2574 (setq string
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2575 (concat
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2576 (char-to-string
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2577 (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
2578 (substring string (match-end 0))))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2579 (if star
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2580 (concat (make-string (1- (length string)) ?\ ) "*")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2581 string)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2582
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2583 (defun reftex-is-multi ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2584 ;; 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
2585 (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
2586 (if entry
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2587 (nth 1 entry)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2588 t)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2589
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2590 (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
2591 ;; 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
2592 (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
2593 (or (eq conf-variable t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2594 (and (stringp conf-variable)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2595 (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
2596
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2597 (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
2598 "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
2599 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
2600 of master file."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2601 (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
2602 (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
2603 (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
2604 file-list tmp file)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2605 (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
2606 (setq file (nth 1 tmp)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2607 all (cdr (memq tmp all)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2608 (and relative
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2609 (string-match re file)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2610 (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
2611 (push file file-list))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2612 (nreverse file-list)))
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 ;;; Creating labels ---------------------------------------------------------
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2615
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2616 (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
2617 "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
2618 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
2619 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
2620 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
2621 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
2622 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
2623 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
2624 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
2625
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2626 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2627
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2628 ;; 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
2629 (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
2630
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2631 ;; 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
2632 (if (or (not environment)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2633 (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
2634 (setq environment (reftex-label-location)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2635 (unless environment
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2636 (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
2637
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2638 ;; Ok, go ahead.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2639 (catch 'exit
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2640 (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
2641 (typekey (nth 1 entry))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2642 (format (nth 3 entry))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2643 (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
2644 (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
2645 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
2646 (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
2647 (memq (preceding-char) '(?\[ ?\{)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2648 ;; 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
2649 (setq naked t format "%s"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2650
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2651 (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
2652 (concat typekey "-")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2653 ;; 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
2654 (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
2655
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2656 ;; Make a default label.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2657 (cond
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 ((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
2660 ;; Derive a label from context.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2661 (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
2662 '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
2663 (symbol-value reftex-docstruct-symbol)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2664 (setq default (reftex-no-props
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2665 (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
2666 ;; 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
2667 (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
2668 (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
2669 (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
2670 (string-match "HOOK ERROR" default)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2671 (string-match "^[ \t]*$" default))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2672 (setq default prefix
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2673 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
2674 (setq default
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2675 (concat prefix
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2676 (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
2677
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2678 ;; Make it unique.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2679 (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
2680
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2681 ((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
2682 ;; 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
2683 (setq default prefix))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2684
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2685 (t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2686 ;; Make an automatic label.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2687 (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
2688
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2689 ;; Should we ask the user?
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2690 (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
2691 (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
2692 force-prompt)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2693
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2694 (while (not valid)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2695 ;; 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
2696
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2697 (setq label (read-string
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2698 (if naked "Naked Label: " "Label: ")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2699 default))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2700
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2701 ;; 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
2702 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2703
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2704 ((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
2705 "\\)?[ \t]*\\'")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2706 label)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2707 ;; No label at all, please
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2708 (message "No label inserted.")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2709 (throw 'exit nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2710
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2711 ;; 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
2712 ((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
2713 (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
2714 (ding)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2715 (sit-for 2))
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 ;; 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
2718 ((setq entry (assoc label
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2719 (symbol-value reftex-docstruct-symbol)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2720 (ding)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2721 (if (y-or-n-p
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2722 (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
2723 (setq valid t)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2724
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2725 ;; Label is ok
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2726 (t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2727 (setq valid t))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2728 (setq label default))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2729
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2730 ;; 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
2731 (let* ((here-I-am-info
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2732 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2733 (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
2734 (integerp (cdr macro-cell)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2735 (goto-char (cdr macro-cell)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2736 (reftex-where-am-I)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2737 (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
2738 (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
2739 ""
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2740 "POSITION UNCERTAIN. RESCAN TO FIX."))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2741 (file (buffer-file-name))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2742 (text nil)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2743 (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
2744
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2745 (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
2746
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2747 (when tail
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2748 (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
2749 (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
2750
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2751 ;; 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
2752 (unless no-insert
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2753 (insert
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2754 (if reftex-format-label-function
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2755 (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
2756 (format format label)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2757 (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
2758 (fboundp 'LaTeX-add-labels))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2759 ;; Tell AUCTeX about this
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2760 (LaTeX-add-labels label)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2761
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2762 ;; 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
2763 (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
2764 (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
2765 (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
2766
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2767 (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
2768 (reftex-parse-one))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2769
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2770 ;; 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
2771 label)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2772
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2773 (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
2774 "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
2775 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
2776 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
2777 (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
2778 (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
2779 (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
2780 (apply 'reftex-convert-string string
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2781 "[-~ \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
2782 reftex-derive-label-parameters))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2783
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2784 (defun reftex-abbreviate-title (string)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2785 (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
2786 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
2787
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2788 (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
2789 nwords maxchar illegal abbrev sep
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2790 ignore-words &optional downcase)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2791 "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
2792 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
2793 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
2794 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
2795 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
2796 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
2797 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
2798 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
2799 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
2800 ABBREV nil: Never abbreviate words.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2801 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
2802 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
2803 string below MAXCHAR.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2804 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
2805 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
2806
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2807 (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
2808 (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
2809 (abbrev-re (concat
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
2810 "\\`\\("
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
2811 (make-string (nth 0 reftex-abbrev-parameters) ?.)
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
2812 "[" (nth 2 reftex-abbrev-parameters) "]*"
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
2813 "\\)"
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
2814 "[" (nth 3 reftex-abbrev-parameters) "]"
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
2815 (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
2816 words word)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2817
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2818 ;; 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
2819 (while (setq word (pop words0))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2820 (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
2821 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2822 ((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
2823 ((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
2824 (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
2825 (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
2826 (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
2827 (push word words)))
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 (push word words))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2830 (setq words (nreverse words))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2831
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2832 ;; Restrict number of words
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2833 (if (> (length words) nwords)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2834 (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
2835
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2836 ;; 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
2837 (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
2838
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2839 ;; 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
2840 (if (or (eq t abbrev)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2841 (and abbrev
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2842 (> (length string) maxchar)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2843 (setq words
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2844 (mapcar
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2845 (function
23344
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
2846 (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
2847 (if dot
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2848 (concat (match-string 1 w) ".")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2849 (match-string 1 w))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2850 w)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2851 words)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2852 string (mapconcat 'identity words sep)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2853
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2854 ;; Shorten if still to long
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2855 (setq string
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2856 (if (> (length string) maxchar)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2857 (substring string 0 maxchar)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2858 string))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2859
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2860 ;; 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
2861 (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
2862 (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
2863 string))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2864
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
2865 (defun reftex-latin1-to-ascii (string)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2866 ;; 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
2867 (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
2868 (emacsp (not (featurep 'xemacs))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2869 (mapconcat
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2870 (lambda (c)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2871 (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
2872 (char-to-string (aref tab (- c 128))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2873 ((and emacsp ; Not for XEmacs
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2874 (> c 2175) (< c 2304)) ; Mule Latin-1
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2875 (char-to-string (aref tab (- c 2176))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2876 (t (char-to-string c))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
2877 string "")))
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
2878
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2879 (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
2880 ;; 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
2881 (save-match-data
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2882 (let (letter (num 0) replace)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2883 (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
2884 (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
2885 (setq replace
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2886 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2887 ((equal letter "f")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2888 (file-name-sans-extension
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2889 (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
2890 ((equal letter "F")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2891 (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
2892 (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
2893 (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
2894 file)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2895 (substring file (length masterdir))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2896 file)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2897 ((equal letter "u")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2898 (or (user-login-name) ""))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2899 (t "")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2900 (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
2901 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
2902 prefix)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2903
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2904 (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
2905 ;; 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
2906 ;; 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
2907 ;; 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
2908
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2909 ;; Ensure access to scanning info
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2910 (reftex-access-scan-info)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2911
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2912 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2913 ((and (not force)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2914 (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
2915 label)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2916 (t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2917 (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
2918 (symbol-value reftex-docstruct-symbol)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2919 (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
2920 (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
2921 (car (setcdr label-numbers
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2922 (cons (cons label 0)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2923 label-numbers-alist)))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2924 (num (1+ (cdr cell)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2925 (sep (or separator "")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2926 (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
2927 (symbol-value reftex-docstruct-symbol))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2928 (incf num))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2929 (setcdr cell num)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2930 (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
2931
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2932 ;;; Referencing labels ------------------------------------------------------
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2933
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2934 ;; 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
2935 (defconst reftex-select-label-prompt
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2936 "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
2937
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2938 (defconst reftex-select-label-help
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2939 " 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
2940 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
2941 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
2942 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
2943 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
2944 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
2945 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
2946 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
2947 [#] label counters, [%] labels in comments
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2948 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
2949 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
2950 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
2951 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
2952
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2953 (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
2954 "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
2955 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
2956 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
2957
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2958 (defun reftex-select-label-mode ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2959 "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
2960 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
2961 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
2962 selection process.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2963 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
2964 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
2965
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2966 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
2967
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2968 \\{reftex-select-label-map}"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2969
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2970 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2971 (kill-all-local-variables)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2972 (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
2973 (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
2974 (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
2975 mode-name "RefTeX Select Label")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2976 (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
2977 (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
2978 ;; 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
2979 (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
2980
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2981 (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
2982 "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
2983 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
2984 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
2985 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
2986 label selection menu.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2987 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
2988 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
2989 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
2990
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2991 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2992
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2993 ;; check for active recursive edits
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2994 (reftex-check-recursive-edit)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2995
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2996 ;; 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
2997 (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
2998
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
2999 (unless type
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3000 ;; guess type from context
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3001 (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
3002 (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
3003 (setq cut (cdr type)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3004 type (car type))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3005 (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
3006
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3007 (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
3008 type reftex-vref-is-default)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3009 "\\vref" "\\ref"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3010 (form "\\ref{%s}")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3011 label pair)
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 ;; 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
3014 (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
3015 (setq pair (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3016 (reftex-offer-label-menu type)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3017 (reftex-ensure-compiled-variables)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3018 (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
3019 (setq label (car pair)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3020 type (cdr pair)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3021 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
3022 form))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3023
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3024 (if (and label
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3025 (not no-insert))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3026 (progn
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3027 (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
3028
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3029 ;; 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
3030 (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
3031 (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
3032 (setq form (substring form 1)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3033 ;; 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
3034 (when (string= varioref "\\vref")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3035 (while (string-match "\\\\ref{" form)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3036 (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
3037 ;; ok, insert the reference
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3038 (insert
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3039 (if reftex-format-ref-function
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3040 (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
3041 (format form label label)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3042 (message ""))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3043 (message "Quit"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3044 ;; return the label
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3045 label))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3046
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3047 (defun reftex-guess-label-type ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3048 ;; 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
3049 (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
3050 (case-fold-search t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3051 (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
3052 matched cell)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3053 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3054 (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
3055 (not (setq matched
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3056 (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
3057 (if matched
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3058 (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
3059 nil)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3060
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3061 (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
3062 ;; 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
3063 (let* ((buf (current-buffer))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3064 (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
3065 (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
3066 (xr-index 0)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3067 (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
3068 (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
3069 (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
3070 (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
3071 (context (not (reftex-typekey-check
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3072 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
3073 (counter (reftex-typekey-check
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3074 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
3075 (follow (reftex-typekey-check
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3076 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
3077 (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
3078 (prefix "")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3079 selection-buffers
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3080 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
3081
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3082 (setq entry (cons nil nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3083
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3084 (unwind-protect
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3085 (catch 'exit
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3086 (while t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3087 (save-window-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3088 (delete-other-windows)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3089 (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
3090 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
3091 (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
3092 (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
3093 (switch-to-buffer-other-window
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3094 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3095 (set-buffer buf)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3096 (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
3097 (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
3098 (reftex-erase-buffer)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3099 (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
3100 (reftex-select-label-mode))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3101 (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
3102 (setq truncate-lines t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3103 (setq mode-line-format
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3104 (list "---- " 'mode-line-buffer-identification
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3105 " " 'varioref
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3106 " " (abbreviate-file-name
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3107 (buffer-file-name buf))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3108 " -%-"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3109 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3110 ((= 0 (buffer-size))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3111 (let ((buffer-read-only nil))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3112 (message "Creating Selection Buffer...")
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3113 (setq offset (reftex-insert-docstruct
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3114 typekey buf toc t files context counter
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3115 commented
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3116 (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
3117 (here-I-am
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3118 (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
3119 (t (setq offset t)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3120 (setq buffer-read-only t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3121 (setq offset (or offset t))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3122
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3123 (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
3124 (setq rtn
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3125 (reftex-select-item
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3126 reftex-select-label-prompt
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3127 reftex-select-label-help
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3128 reftex-select-label-map
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3129 offset
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3130 '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
3131 (setq key (car rtn)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3132 data (nth 1 rtn)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3133 last-data (nth 2 rtn)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3134 offset t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3135 (unless key (throw 'exit nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3136 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3137 ((eq key ?g)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3138 ;; update buffer
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3139 (reftex-erase-buffer))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3140 ((or (eq key ?r)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3141 (eq key ?R))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3142 ;; rescan buffer
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3143 (reftex-erase-buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3144 (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
3145 ((eq key ?c)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3146 ;; toggle context mode
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3147 (reftex-erase-buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3148 (setq context (not context)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3149 ((eq key ?s)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3150 ;; switch type
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3151 (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
3152 (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
3153 ((eq key ?t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3154 ;; toggle table of contents display
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3155 (reftex-erase-buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3156 (setq toc (not toc)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3157 ((eq key ?i)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3158 ;; 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
3159 (reftex-erase-buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3160 (setq files (not files)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3161 ((eq key ?#)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3162 ;; toggle counter display
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3163 (reftex-erase-buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3164 (setq counter (not counter)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3165 ((eq key ?%)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3166 ;; toggle display of commented labels
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3167 (reftex-erase-buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3168 (setq commented (not commented)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3169 ((eq key ?l)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3170 ;; 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
3171 (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
3172 (throw 'exit t))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3173 ((eq key ?x)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3174 ;; select an external document
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3175 (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
3176 xr-alist xr-index))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3177 (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
3178 (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
3179 (error "Cannot switch document"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3180 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
3181 (set-buffer buf)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3182 (reftex-access-scan-info))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3183 ((stringp key)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3184 (setq entry
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3185 (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
3186 (list key typekey)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3187 (throw 'exit t))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3188 (t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3189 (set-buffer buf)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3190 (if data
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3191 (progn
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3192 (setq entry data)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3193 (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
3194 (setq entry nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3195 (throw 'exit t))))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3196 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3197 (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
3198 (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
3199 (setq buffer-invisibility-spec
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3200 (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
3201 (mapcar (function (lambda (buf)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3202 (and (buffer-live-p buf)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3203 (bury-buffer buf))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3204 selection-buffers)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3205 (reftex-kill-temporary-buffers))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3206 (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
3207 (nth 1 entry))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3208
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3209 (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
3210 ;; 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
3211 (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
3212 (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
3213 ?0 highest))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3214 key prefix)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3215 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3216 ((= len 1)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3217 (message "No external documents available")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3218 (ding) (sit-for 1) 0)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3219 ((= len 2)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3220 (- 1 xr-index))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3221 (t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3222 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3223 (let* ((length (apply 'max (mapcar
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3224 (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
3225 (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
3226 (n (1- ?0)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3227 (setq key
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3228 (reftex-select-with-char
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3229 prompt
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3230 (concat
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3231 "SELECT EXTERNAL DOCUMENT\n------------------------\n"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3232 (mapconcat
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3233 (function
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3234 (lambda (x)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3235 (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
3236 (abbreviate-file-name (cdr x)))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3237 xr-alist ""))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3238 nil t))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3239 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3240 ((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
3241 ((= key ?\C-i)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3242 (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
3243 (- 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
3244 (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
3245
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3246 (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
3247 ;; Rescan the document.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3248 (save-window-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3249 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3250 (if buffer
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3251 (if (not (bufferp buffer))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3252 (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
3253 (set-buffer buffer)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3254 (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
3255 (file (nth 3 data)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3256 (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
3257
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3258 (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
3259 ;; 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
3260 (format " *RefTeX[%s][%d]*"
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
3261 type (or index (get reftex-docstruct-symbol :master-index) 0)))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3262
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3263 (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
3264 ;; 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
3265 ;; 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
3266 ;; 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
3267 ;; 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
3268 (catch 'exit
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3269 (save-excursion
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3270 (set-buffer buf)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3271 (reftex-access-scan-info)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3272 (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
3273 entry)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3274 (while (setq entry (pop rest))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3275 (if (or (and typekey
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3276 (stringp (car entry))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3277 (or (equal typekey " ")
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3278 (equal typekey (nth 1 entry))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3279 (and toc (eq (car entry) 'toc))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3280 (and file
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3281 (memq (car entry) '(bof eof file-error))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3282 (throw 'exit entry)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3283 nil))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3284
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3285 (defun reftex-insert-docstruct
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3286 (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
3287 here-I-am xr-prefix toc-buffer)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3288 ;; 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
3289 ;; 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
3290 ;; 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
3291 ;; 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
3292 ;; 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
3293 ;; 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
3294 ;; 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
3295 ;; COUNTER means to count the labels.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3296 ;; 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
3297 ;; 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
3298 ;; 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
3299 ;; 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
3300 ;; 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
3301 (let* ((font (reftex-use-fonts))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3302 (cnt 0)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3303 (index -1)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3304 (toc-indent " ")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3305 (label-indent
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3306 (concat "> "
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3307 (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
3308 (context-indent
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3309 (concat ". "
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3310 (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
3311 (mouse-face
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3312 (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
3313 reftex-mouse-selected-face
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3314 nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3315 (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
3316 'font-lock-constant-face
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3317 'font-lock-reference-face))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3318 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
3319 offset from to docstruct-symbol)
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 ;; 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
3322 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3323 (set-buffer buf)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3324
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3325 ;; Ensure access to scanning info
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3326 (reftex-access-scan-info)
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 docstruct-symbol reftex-docstruct-symbol
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3329 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
3330 reftex-active-toc nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3331 master-dir-re
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3332 (concat "\\`" (regexp-quote
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3333 (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
3334
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3335 (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
3336 (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
3337 (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
3338 (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
3339
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3340 ;; 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
3341 (while (setq cell (pop all))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3342
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3343 (incf index)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3344 (setq from (point))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3345
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3346 (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
3347
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3348 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3349
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3350 ((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
3351 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
3352 ;; These are currently ignored
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 ((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
3355 ;; 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
3356 (when files
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3357 (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
3358 (insert
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3359 " 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
3360 (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
3361 (nth 1 cell))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3362 (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
3363 ((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
3364 ((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
3365 (setq to (point))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3366 (when font
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3367 (put-text-property from to
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3368 'face reftex-file-boundary-face))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3369 (when toc-buffer
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3370 (if mouse-face
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3371 (put-text-property from (1- to)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3372 'mouse-face mouse-face))
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
3373 (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
3374
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3375 ((eq (car cell) 'toc)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3376 ;; a table of contents entry
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3377 (when toc
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3378 (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
3379 (setq reftex-active-toc cell)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3380 (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
3381 (setq to (point))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3382 (when font
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3383 (put-text-property from to
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3384 'face reftex-section-heading-face))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3385 (when toc-buffer
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3386 (if mouse-face
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3387 (put-text-property from (1- to)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3388 'mouse-face mouse-face))
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
3389 (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
3390 (goto-char to)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3391
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3392 ((stringp (car cell))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3393 ;; a label
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3394 (when (null (nth 2 cell))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3395 ;; No context yet. Quick update.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3396 (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
3397 (put docstruct-symbol 'modified t))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3398
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3399 (setq label (car cell)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3400 typekey (nth 1 cell)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3401 text (nth 2 cell)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3402 comment (nth 4 cell)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3403 note (nth 5 cell))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3404
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3405 (when (and labels
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3406 (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
3407 (or show-commented (null comment)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3408
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3409 ;; Yes we want this one
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3410 (incf cnt)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3411 (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
3412
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3413 (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
3414 (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
3415 (insert label-indent label)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3416 (when font
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3417 (setq to (point))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3418 (put-text-property
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3419 (- (point) (length label)) to
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3420 'face (if comment
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3421 'font-lock-comment-face
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3422 label-face))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3423 (goto-char to))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3424
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3425 (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
3426 (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
3427 (if (stringp note) (concat " " note) "")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3428 "\n")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3429 (setq to (point))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3430
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3431 (when context
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3432 (insert context-indent text "\n")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3433 (setq to (point)))
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
3434 (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
3435 (when mouse-face
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3436 (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
3437 'mouse-face mouse-face))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3438 (goto-char to)))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3439
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3440 (when (reftex-refontify)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3441 ;; 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
3442 (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
3443 (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
3444 offset))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3445
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3446 (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
3447 ;; Set point to the first available LOCATION. When a LOCATION is a list,
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
3448 ;; search for such a :data text property. When it is an integer,
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3449 ;; 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
3450 ;; else fails.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3451 (catch 'exit
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3452 (goto-char (point-min))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3453 (let (loc pos)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3454 (while locations
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3455 (setq loc (pop locations))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3456 (cond
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3457 ((null loc))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3458 ((listp loc)
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
3459 (setq pos (text-property-any (point-min) (point-max) :data loc))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3460 (when pos
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3461 (goto-char pos)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3462 (throw 'exit t)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3463 ((integerp loc)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3464 (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
3465 (goto-line loc)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3466 (throw 'exit t)))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3467 (goto-char fallback))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3468
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3469 (defun reftex-query-label-type ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3470 ;; Ask for label type
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3471 (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
3472 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
3473 (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
3474 (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
3475 (char-to-string key)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3476
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3477 (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
3478 &optional stay error)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3479 ;; 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
3480 ;; 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
3481 ;; 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
3482 ;; 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
3483 ;; STAY means leave the new window selected.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3484 ;; 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
3485 ;; 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
3486 (let* ((this-window (selected-window))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3487 (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
3488 label file buffer re found)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3489
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3490 (catch 'exit
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3491 (setq label (nth 0 data)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3492 file (nth 3 data))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3493
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3494 (unless file
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3495 (funcall errorf "Unknown label - reparse might help")
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3496 (throw 'exit nil))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3497
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3498 ;; 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
3499 (setq buffer
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3500 (if no-revisit
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3501 (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
3502 (reftex-get-file-buffer-force
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3503 file (not reftex-keep-temporary-buffers))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3504 (if buffer
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3505 ;; good - the file is available
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3506 (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
3507 ;; we have got a problem here. The file does not exist.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3508 ;; Let' get out of here..
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3509 (funcall errorf "Label %s not found" label)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3510 (throw 'exit nil))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3511
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3512 ;; search for that label
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3513 (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
3514 (setq found
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3515 (if forward
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3516 (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
3517 (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
3518 (unless found
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3519 (goto-char (point-min))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3520 (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
3521 ;; 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
3522 (setq found
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3523 (re-search-forward
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3524 (format reftex-find-label-regexp-format2
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3525 (regexp-quote label)) nil t))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3526 (if (match-end 3)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3527 (progn
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3528 (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
3529 (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
3530 (recenter '(4))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3531 (unless stay (select-window this-window)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3532 (select-window this-window)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3533 (funcall errorf "Label %s not found" label))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3534 found)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3535
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3536 (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
3537 ;; Show entry if point is hidden
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
3538 (let* ((n (/ (reftex-window-height) 2))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3539 (beg (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3540 (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
3541 (end (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3542 (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
3543 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3544 ((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
3545 (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
3546 ;; 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
3547 (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
3548 reftex-buffers-with-changed-invisibility)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3549 (setq buffer-invisibility-spec nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3550 ((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
3551 ;; 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
3552 (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
3553 (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
3554 (setq buffer-read-only nil)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3555 (erase-buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3556 (insert string)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3557 (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
3558 (goto-char (- beg-hlt beg))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3559 (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
3560 (if (reftex-refontify)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3561 (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
3562 (not font-lock-mode))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3563 (latex-mode)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3564 (run-hook-with-args
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3565 'reftex-pre-refontification-functions
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3566 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
3567 (turn-on-font-lock))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3568 (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
3569 font-lock-mode)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3570 (fundamental-mode)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3571 (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
3572 (setq buffer-read-only t))))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3573
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3574 ;;; =========================================================================
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3575 ;;;
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3576 ;;; Table of contents
18050
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 ;; 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
3579
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3580 (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
3581 "Keymap used for *toc* buffer.")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3582
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3583 (defun reftex-toc-mode ()
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3584 "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
3585 This buffer was created with RefTeX.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3586 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
3587
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3588 Here are all local bindings.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3589
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3590 \\{reftex-toc-map}"
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3591 (interactive)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3592 (kill-all-local-variables)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3593 (setq major-mode 'reftex-toc-mode
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3594 mode-name "RefTeX Table of Contents")
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3595 (use-local-map reftex-toc-map)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3596 (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
3597 (setq truncate-lines t)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3598 (make-local-hook 'post-command-hook)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3599 (make-local-hook 'pre-command-hook)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3600 (make-local-variable 'reftex-last-follow-point)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3601 (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
3602 (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
3603 (run-hooks 'reftex-toc-mode-hook))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3604
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3605 (defvar reftex-last-toc-master nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3606 "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
3607
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3608 (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
3609 "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
3610
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3611 (defvar reftex-last-window-height nil)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3612
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3613 (defvar reftex-toc-return-marker (make-marker)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3614 "Marker which makes it possible to return from toc to old position.")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3615
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3616 (defconst reftex-toc-help
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3617 " AVAILABLE KEYS IN TOC BUFFER
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3618 ============================
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3619 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
3620 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
3621 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
3622 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
3623 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
3624 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
3625 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
3626 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
3627 . 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
3628 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
3629
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3630 (defun reftex-toc (&optional rebuild)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3631 "Show the table of contents for the current document.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3632 When called with a raw C-u prefix, rescan the document first."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3633
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3634 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3635
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3636 (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
3637 current-prefix-arg)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3638 (reftex-erase-buffer "*toc*"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3639
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3640 (setq reftex-last-toc-file (buffer-file-name))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3641 (setq reftex-last-toc-master (reftex-TeX-master-file))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3642
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3643 (set-marker reftex-toc-return-marker (point))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3644
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3645 ;; If follow mode is active, arrange to delay it one command
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3646 (if reftex-toc-follow-mode
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3647 (setq reftex-toc-follow-mode 1))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3648
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3649 ;; 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
3650 (reftex-access-scan-info current-prefix-arg)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3651
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3652 (let* ((this-buf (current-buffer))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3653 (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
3654 (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
3655 (here-I-am (if rebuild
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
3656 (get 'reftex-toc :reftex-data)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3657 (car (reftex-where-am-I))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3658 offset)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3659
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3660 (if (get-buffer-window "*toc*")
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3661 (select-window (get-buffer-window "*toc*"))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3662 (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
3663 (< (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
3664 (delete-other-windows))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3665 (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
3666 (split-window)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3667 (let ((default-major-mode 'reftex-toc-mode))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3668 (switch-to-buffer "*toc*")))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3669
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3670 (or (eq major-mode 'reftex-toc-mode) (reftex-toc-mode))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3671
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3672 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3673 ((= (buffer-size) 0)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3674 ;; 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
3675 (message "Building *toc* buffer...")
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3676
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3677 (setq buffer-read-only nil)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3678 (insert (format
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3679 "TABLE-OF-CONTENTS on %s
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3680 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
3681 ------------------------------------------------------------------------------
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3682 " (abbreviate-file-name reftex-last-toc-master)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3683
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3684 (if (reftex-use-fonts)
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
3685 (put-text-property 1 (point) 'face reftex-toc-header-face))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3686 (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
3687 (put-text-property 1 2 'xr-alist xr-alist)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3688
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3689 (setq offset
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3690 (reftex-insert-docstruct
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3691 " "
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3692 this-buf
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3693 t ; toc
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3694 reftex-toc-include-labels
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3695 reftex-toc-include-file-boundaries
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3696 reftex-toc-include-context
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3697 nil ; counter
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3698 nil ; commented
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3699 here-I-am "" t))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3700
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3701 (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
3702 (message "Building *toc* buffer...done.")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3703 (setq buffer-read-only t))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3704 (t
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3705 ;; Only compute the offset
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3706 (setq offset
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3707 (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
3708 (if reftex-toc-include-labels " " nil)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3709 t
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3710 reftex-toc-include-file-boundaries)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3711 (reftex-last-assoc-before-elt
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3712 'toc here-I-am
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3713 (symbol-value reftex-docstruct-symbol))))
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
3714 (put 'reftex-toc :reftex-line 3)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3715 (goto-line 3)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3716 (beginning-of-line)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3717
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3718 ;; Find the correct starting point
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
3719 (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
3720 (setq reftex-last-follow-point (point))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3721
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3722 (defun reftex-toc-pre-command-hook ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3723 ;; used as pre command hook in *toc* buffer
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3724 (reftex-unhighlight 0)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3725 (reftex-unhighlight 1))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3726
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3727 (defun reftex-toc-post-command-hook ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3728 ;; used in the post-command-hook for the *toc* buffer
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
3729 (when (get-text-property (point) :data)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
3730 (put 'reftex-toc :reftex-data (get-text-property (point) :data))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3731 (and (> (point) 1)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3732 (not (get-text-property (point) 'intangible))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3733 (memq reftex-highlight-selection '(cursor both))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3734 (reftex-highlight 1
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
3735 (or (previous-single-property-change (1+ (point)) :data)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3736 (point-min))
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
3737 (or (next-single-property-change (point) :data)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3738 (point-max)))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3739 (if (integerp reftex-toc-follow-mode)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3740 ;; remove delayed action
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3741 (setq reftex-toc-follow-mode t)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3742 (and reftex-toc-follow-mode
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3743 (not (equal reftex-last-follow-point (point)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3744 ;; show context in other window
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3745 (setq reftex-last-follow-point (point))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3746 (condition-case nil
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3747 (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
3748 (error t)))))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3749
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3750 (defun reftex-re-enlarge ()
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3751 ;; 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
3752 (enlarge-window
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3753 (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
3754 (window-height)))))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3755
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3756 (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
3757 "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
3758 (interactive)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3759 (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
3760 (princ reftex-toc-help))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3761 ;; 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
3762 (if reftex-toc-follow-mode
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3763 (setq reftex-toc-follow-mode 1)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3764
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3765 (defun reftex-toc-next (&optional arg)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3766 "Move to next selectable item."
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3767 (interactive "p")
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3768 (setq reftex-callback-fwd t)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3769 (or (eobp) (forward-char 1))
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
3770 (goto-char (or (next-single-property-change (point) :data)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3771 (point))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3772 (defun reftex-toc-previous (&optional arg)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3773 "Move to previous selectable item."
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3774 (interactive "p")
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3775 (setq reftex-callback-fwd nil)
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
3776 (goto-char (or (previous-single-property-change (point) :data)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3777 (point))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3778 (defun reftex-toc-toggle-follow ()
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3779 "Toggle follow (other window follows with context)."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3780 (interactive)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3781 (setq reftex-last-follow-point -1)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3782 (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
3783 (defun reftex-toc-toggle-file-boundary ()
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3784 "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
3785 (interactive)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3786 (setq reftex-toc-include-file-boundaries
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3787 (not reftex-toc-include-file-boundaries))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3788 (reftex-toc-revert))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3789 (defun reftex-toc-toggle-labels ()
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3790 "Toggle inclusion of labels in *toc* buffer."
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3791 (interactive)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3792 (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
3793 (reftex-toc-revert))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3794 (defun reftex-toc-toggle-context ()
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3795 "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
3796 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
3797 (interactive)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3798 (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
3799 (reftex-toc-revert))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3800 (defun reftex-toc-view-line ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3801 "View document location in other window."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3802 (interactive)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3803 (reftex-toc-visit-location))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3804 (defun reftex-toc-mouse-view-line (ev)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3805 "View document location in other window."
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3806 (interactive "e")
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3807 (mouse-set-point ev)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3808 (reftex-toc-visit-location))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3809 (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
3810 "Go to document location in other window. Hide the *toc* window."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3811 (interactive)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3812 (reftex-toc-visit-location 'hide))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3813 (defun reftex-toc-goto-line ()
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3814 "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
3815 (interactive)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3816 (reftex-toc-visit-location t))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3817 (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
3818 "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
3819 (interactive "e")
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3820 (mouse-set-point ev)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3821 (reftex-toc-visit-location 'hide))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3822 (defun reftex-toc-show-calling-point ()
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3823 "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
3824 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3825 (let ((this-window (selected-window)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3826 (unwind-protect
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3827 (progn
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3828 (switch-to-buffer-other-window
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3829 (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
3830 (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
3831 (recenter '(4)))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3832 (select-window this-window))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3833 (defun reftex-toc-quit ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3834 "Hide the *toc* window and do not move point."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3835 (interactive)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3836 (or (one-window-p) (delete-window))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3837 (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
3838 (reftex-re-enlarge)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3839 (goto-char (or (marker-position reftex-toc-return-marker) (point))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3840 (defun reftex-toc-quit-and-kill ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3841 "Kill the *toc* buffer."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3842 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3843 (kill-buffer "*toc*")
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3844 (or (one-window-p) (delete-window))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3845 (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
3846 (reftex-re-enlarge)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3847 (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
3848 (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
3849 "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
3850 (interactive)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3851 (if reftex-enable-partial-scans
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
3852 (let* ((data (get-text-property (point) :data))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3853 (what (car data))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3854 (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
3855 ((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
3856 ((stringp what) (nth 3 data))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3857 (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
3858 (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
3859 (error "Don't know which file to rescan. Try `R'")
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
3860 (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
3861 (switch-to-buffer-other-window
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3862 (reftex-get-file-buffer-force file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3863 (setq current-prefix-arg '(4))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3864 (reftex-toc t)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3865 (reftex-toc-Rescan))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3866 (reftex-kill-temporary-buffers))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3867 (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
3868 "Regenerate the *toc* buffer by reparsing the entire document."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3869 (interactive)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3870 (switch-to-buffer-other-window
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3871 (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
3872 (setq current-prefix-arg '(16))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3873 (reftex-toc t))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3874 (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
3875 "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
3876 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3877 (switch-to-buffer-other-window
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3878 (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
3879 (reftex-erase-buffer "*toc*")
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3880 (setq current-prefix-arg nil)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3881 (reftex-toc t))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3882 (defun reftex-toc-external (&rest ignore)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3883 "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
3884 (interactive)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3885 (let* ((old-buf (current-buffer))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3886 (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
3887 (xr-index (reftex-select-external-document
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3888 xr-alist 0)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3889 (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
3890 (cdr (nth xr-index xr-alist)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3891 (error "Cannot switch document")))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3892 (reftex-toc)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3893 (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
3894 (message "")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3895 (message "Switched document"))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3896
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3897 (defun reftex-toc-visit-location (&optional final no-revisit)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3898 ;; 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
3899 ;; If FINAL is t, stay there
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3900 ;; 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
3901 ;; 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
3902 ;; 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
3903 ;; 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
3904 ;; 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
3905 ;; have been active.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3906
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
3907 (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
3908 (toc-window (selected-window))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3909 show-window show-buffer match)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3910
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3911 (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
3912
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3913 (cond
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3914
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3915 ((eq (car toc) 'toc)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3916 ;; a toc entry
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3917 (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
3918
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3919 ((memq (car toc) '(bof eof))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3920 ;; A file entry
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3921 (setq match
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3922 (let ((where (car toc))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3923 (file (nth 1 toc)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3924 (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
3925 (progn
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3926 (switch-to-buffer-other-window
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3927 (reftex-get-file-buffer-force file nil))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3928 (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
3929 (message reftex-no-follow-message) nil))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3930
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3931 ((stringp (car toc))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3932 ;; a label
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3933 (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
3934 no-revisit t))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3935
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3936 (setq show-window (selected-window)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3937 show-buffer (current-buffer))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3938
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3939 (unless match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3940 (select-window toc-window)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3941 (error "Cannot find location"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3942
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3943 (select-window toc-window)
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 ;; use the `final' parameter to decide what to do next
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3946 (cond
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3947 ((eq final t)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3948 (reftex-unhighlight 0)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3949 (select-window show-window))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3950 ((eq final 'hide)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3951 (reftex-unhighlight 0)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3952 (or (one-window-p) (delete-window))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3953 (switch-to-buffer show-buffer)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3954 (reftex-re-enlarge))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3955 (t nil))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3956
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3957 (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
3958 (let* ((file (nth 3 toc))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3959 (marker (nth 4 toc))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3960 (level (nth 5 toc))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3961 (literal (nth 7 toc))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3962 (emergency-point (nth 8 toc))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3963 (match
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3964 (cond
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3965 ((and (markerp marker) (marker-buffer marker))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3966 ;; 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
3967 (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
3968 (goto-char (marker-position marker))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3969 (or (looking-at (regexp-quote literal))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3970 (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
3971 (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
3972 (looking-at (concat "\\\\"
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3973 (regexp-quote
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3974 (car
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3975 (rassq level
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3976 reftex-section-levels-all)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3977 "[[{]"))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3978 ((or (not no-revisit)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3979 (reftex-get-buffer-visiting file))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3980 ;; Marker is lost. Use the backup method.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3981 (switch-to-buffer-other-window
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3982 (reftex-get-file-buffer-force file nil))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3983 (goto-char (or emergency-point (point-min)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3984 (or (looking-at (regexp-quote literal))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3985 (let ((pos (point)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3986 (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
3987 (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
3988 (reftex-nearest-match
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3989 (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
3990 (reftex-nearest-match
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3991 (reftex-make-desperate-section-regexp literal) pos)))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3992 (t (message reftex-no-follow-message) nil))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3993 (when match
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3994 (goto-char (match-beginning 0))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3995 (if (not (= (point) (point-max))) (recenter 1))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3996 (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
3997 match))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
3998
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
3999 (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
4000 ;; 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
4001 ;; 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
4002 (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
4003 (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
4004 (old (substring old n)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4005 (while (string-match
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4006 "\\([\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
4007 old)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4008 (if (match-beginning 1)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4009 (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
4010 (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
4011 (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
4012 new))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4013
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4014 ;;; =========================================================================
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4015 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4016 ;;; BibTeX citations.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4017
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4018 ;; Variables and constants
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4019
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4020 ;; The history list of regular expressions used for citations
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4021 (defvar reftex-cite-regexp-hist nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4022
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4023 ;; 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
4024 (defconst reftex-citation-prompt
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4025 "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
4026
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4027 (defconst reftex-citation-help
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4028 " 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
4029 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
4030 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
4031 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
4032 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
4033 . Show insertion point.
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4034 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
4035 TAB Enter citation key with completion.
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4036 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
4037 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
4038
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4039 (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
4040 "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
4041 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
4042 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
4043
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4044 (defun reftex-select-bib-mode ()
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4045 "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
4046 This buffer was created with RefTeX.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4047 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
4048 selection process.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4049 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
4050 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
4051
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4052 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
4053
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4054 \\{reftex-select-label-map}"
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4055 (interactive)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4056 (kill-all-local-variables)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4057 (make-local-hook 'pre-command-hook)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4058 (make-local-hook 'post-command-hook)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4059 (setq major-mode 'reftex-select-bib-mode
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4060 mode-name "RefTeX Select Bib")
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4061 ;; 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
4062 (run-hooks 'reftex-select-bib-mode-hook))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4063
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4064 ;; Find bibtex files
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4065
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4066 (defun reftex-get-bibfile-list ()
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4067 ;; 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
4068 ;; 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
4069 ;; 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
4070 ;; 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
4071 ;; Then this function will return the applicable database files.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4072
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4073 ;; Ensure access to scanning info
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4074 (reftex-access-scan-info)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4075 (or
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4076 ;; 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
4077 (cdr (reftex-last-assoc-before-elt
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4078 'bib (list 'eof (buffer-file-name))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4079 (member (list 'bof (buffer-file-name))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4080 (symbol-value reftex-docstruct-symbol))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4081 ;; 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
4082 (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
4083 (symbol-value reftex-docstruct-symbol))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4084 ;; Anywhere in the entire document
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4085 (cdr (assq 'bib (symbol-value reftex-docstruct-symbol)))
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
4086 (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
4087
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4088 ;; Find a certain reference in any of the BibTeX files.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4089
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4090 (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
4091 highlight item return)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4092 ;; 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
4093 ;; 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
4094 ;; 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
4095 ;; 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
4096 ;; 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
4097
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4098 (let* ((re
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4099 (if item
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4100 (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
4101 (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
4102 "[, \t\r\n}]")))
24898
bd105cd3c084 (reftex-pop-to-bibtex-entry): don't pop up
Karl Heuer <kwzh@gnu.org>
parents: 24389
diff changeset
4103 (buffer-conf (current-buffer))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4104 file buf)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4105
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4106 (catch 'exit
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4107 (while file-list
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4108 (setq file (car file-list)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4109 file-list (cdr file-list))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4110 (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
4111 (error "No such file %s" file))
24898
bd105cd3c084 (reftex-pop-to-bibtex-entry): don't pop up
Karl Heuer <kwzh@gnu.org>
parents: 24389
diff changeset
4112 (set-buffer buf)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4113 (widen)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4114 (goto-char (point-min))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4115 (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
4116 (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
4117 (when return
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4118 ;; 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
4119 (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
4120 (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
4121 (point) (reftex-end-of-bib-entry item)))
24898
bd105cd3c084 (reftex-pop-to-bibtex-entry): don't pop up
Karl Heuer <kwzh@gnu.org>
parents: 24389
diff changeset
4122 (set-buffer buffer-conf)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4123 (throw 'exit return))
24898
bd105cd3c084 (reftex-pop-to-bibtex-entry): don't pop up
Karl Heuer <kwzh@gnu.org>
parents: 24389
diff changeset
4124 (switch-to-buffer-other-window buffer-conf)
bd105cd3c084 (reftex-pop-to-bibtex-entry): don't pop up
Karl Heuer <kwzh@gnu.org>
parents: 24389
diff changeset
4125 (switch-to-buffer buf)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4126 (recenter 0)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4127 (if highlight
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4128 (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
4129 (throw 'exit (selected-window))))
24898
bd105cd3c084 (reftex-pop-to-bibtex-entry): don't pop up
Karl Heuer <kwzh@gnu.org>
parents: 24389
diff changeset
4130 (set-buffer buffer-conf)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4131 (if item
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4132 (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
4133 (error "No BibTeX entry with citation key %s" key)))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4134
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
4135 (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
4136 (save-excursion
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
4137 (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
4138 (if item
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
4139 (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
4140 (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
4141 "\\\\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
4142 (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
4143 (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
4144 (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
4145
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4146 ;; Parse bibtex buffers
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4147
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4148 (defun reftex-extract-bib-entries (buffers)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4149 ;; Extract bib entries which match regexps from BUFFERS.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4150 ;; BUFFERS is a list of buffers or file names.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4151 ;; Return list with entries."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4152 (let* (re-list first-re rest-re
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4153 (buffer-list (if (listp buffers) buffers (list buffers)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4154 found-list entry buffer1 buffer alist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4155 key-point start-point end-point)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4156
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4157 ;; 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
4158 (setq re-list
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4159 (split-string
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4160 (completing-read
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4161 "RegExp [ && RegExp...]: "
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
4162 (if reftex-mode
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
4163 (if (fboundp 'LaTeX-bibitem-list)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
4164 (LaTeX-bibitem-list)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
4165 (cdr (assoc 'bibview-cache
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
4166 (symbol-value reftex-docstruct-symbol))))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
4167 nil)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4168 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
4169 "[ \t]*&&[ \t]*"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4170
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4171 (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
4172 rest-re (cdr re-list)) ; the others to narrow down.
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
4173 (if (string-match "\\`[ \t]*\\'" (or first-re ""))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4174 (error "Empty regular expression"))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4175
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4176 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4177 (save-window-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4178
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4179 ;; Walk through all bibtex files
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4180 (while buffer-list
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4181 (setq buffer (car buffer-list)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4182 buffer-list (cdr buffer-list))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4183 (if (and (bufferp buffer)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4184 (buffer-live-p buffer))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4185 (setq buffer1 buffer)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4186 (setq buffer1 (reftex-get-file-buffer-force
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4187 buffer (not reftex-keep-temporary-buffers))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4188 (if (not buffer1)
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
4189 (message "No such BibTeX file %s (ignored)" buffer)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4190 (message "Scanning bibliography database %s" buffer1))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4191
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4192 (set-buffer buffer1)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4193 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4194 (goto-char (point-min))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4195 (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
4196 (catch 'search-again
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4197 (setq key-point (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4198 (unless (re-search-backward
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4199 "\\(\\`\\|[\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
4200 (throw 'search-again nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4201 (setq start-point (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4202 (goto-char (match-end 0))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4203 (condition-case nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4204 (up-list 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4205 (error (goto-char key-point)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4206 (throw 'search-again nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4207 (setq end-point (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4208
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4209 ;; 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
4210 ;; outside entries
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4211 (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
4212 (string= (downcase (match-string 2)) "comment")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4213 (string= (downcase (match-string 2)) "c")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4214 (< (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
4215 (goto-char key-point)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4216 (throw 'search-again nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4217
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4218 ;; Well, we have got a match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4219 (setq entry (concat
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4220 (buffer-substring start-point (point)) "\n"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4221
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4222 ;; 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
4223 (setq re-list rest-re)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4224 (while re-list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4225 (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
4226 ;; nope - move on
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4227 (throw 'search-again nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4228 (pop re-list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4229
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4230 (setq alist (reftex-parse-bibtex-entry
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4231 nil start-point end-point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4232 (push (cons "&entry" entry) alist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4233
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4234 ;; check for crossref entries
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4235 (if (assoc "crossref" alist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4236 (setq alist
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4237 (append
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4238 alist (reftex-get-crossref-alist alist))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4239
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4240 ;; format the entry
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4241 (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
4242 alist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4243
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4244 ;; make key the first element
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4245 (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
4246
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4247 ;; add it to the list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4248 (push alist found-list))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4249 (reftex-kill-temporary-buffers))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4250 (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
4251
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4252 ;; Sorting
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4253 (cond
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4254 ((eq 'author reftex-sort-bibtex-matches)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4255 (sort found-list 'reftex-bib-sort-author))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4256 ((eq 'year reftex-sort-bibtex-matches)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4257 (sort found-list 'reftex-bib-sort-year))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4258 ((eq 'reverse-year reftex-sort-bibtex-matches)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4259 (sort found-list 'reftex-bib-sort-year-reverse))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4260 (t found-list))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4261
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4262 (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
4263 (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
4264 (al2 (reftex-get-bib-names "author" e2)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4265 (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
4266 (pop al1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4267 (pop al2))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4268 (if (and (stringp (car al1))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4269 (stringp (car al2)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4270 (string< (car al1) (car al2))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4271 (not (stringp (car al1))))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4272
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4273 (defun reftex-bib-sort-year (e1 e2)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4274 (< (string-to-int (cdr (assoc "year" e1)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4275 (string-to-int (cdr (assoc "year" e2)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4276
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4277 (defun reftex-bib-sort-year-reverse (e1 e2)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4278 (> (string-to-int (or (cdr (assoc "year" e1)) "0"))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4279 (string-to-int (or (cdr (assoc "year" e2)) "0"))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4280
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4281 (defun reftex-get-crossref-alist (entry)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4282 ;; return the alist from a crossref entry
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4283 (let ((crkey (cdr (assoc "crossref" entry)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4284 start)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4285 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4286 (save-restriction
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4287 (widen)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4288 (if (re-search-forward
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4289 (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
4290 "[ \t\n\r]*,") nil t)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4291 (progn
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4292 (setq start (match-beginning 0))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4293 (condition-case nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4294 (up-list 1)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4295 (error nil))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4296 (reftex-parse-bibtex-entry nil start (point)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4297 nil)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4298
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4299 ;; Parse the thebibliography environment
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4300 (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
4301 ;; 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
4302 ;; 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
4303 ;; 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
4304
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4305 (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
4306 (unless file
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4307 (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
4308 (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
4309 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
4310 (unless buf
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4311 (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
4312 (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
4313
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4314 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4315 (set-buffer buf)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4316 (save-restriction
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4317 (widen)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4318 (goto-char (point-min))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4319 (if (re-search-forward
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4320 "\\(\\`\\|[\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
4321 (progn
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4322 (beginning-of-line 2)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4323 (setq start (point))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4324 (if (re-search-forward
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4325 "\\(\\`\\|[\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
4326 (progn
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4327 (beginning-of-line 1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4328 (setq end (point))))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4329 (when (and start end)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4330 (setq entries
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4331 (mapcar 'reftex-parse-bibitem
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4332 (delete ""
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4333 (split-string
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4334 (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
4335 "[ \t\n\r]*\\\\bibitem\\(\\[[^]]*]\\)*")))))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4336 (unless entries
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4337 (error "No bibitems found"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4338
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4339 (setq re-list (split-string
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4340 (read-string "RegExp [ && RegExp...]: "
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4341 nil 'reftex-cite-regexp-hist)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4342 "[ \t]*&&[ \t]*"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4343 (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
4344 (error "Empty regular expression"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4345
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4346 (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
4347 (setq entries
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4348 (delq nil (mapcar
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4349 (function
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4350 (lambda (x)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4351 (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
4352 x nil)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4353 entries))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4354 (setq entries
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4355 (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4356 (lambda (x)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4357 (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
4358 (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
4359 x)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4360 entries))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4361
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4362 entries))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4363
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4364 ;; Parse and format individual entries
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4365
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4366 (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
4367 ;; 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
4368 (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
4369 (if (equal "" names)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4370 (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
4371 (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
4372 (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
4373 (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
4374 (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
4375 (while (string-match "^[ \t]+\\|[ \t]+$" names)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4376 (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
4377 (while (string-match "[ \t][ \t]+" names)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4378 (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
4379 (split-string names "\n")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4380
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4381 (defun reftex-parse-bibtex-entry (entry &optional from to)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4382 (let (alist key start field)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4383 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4384 (save-restriction
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4385 (if entry
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4386 (progn
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4387 (set-buffer (get-buffer-create " *RefTeX-scratch*"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4388 (fundamental-mode)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4389 (erase-buffer)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4390 (insert entry))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4391 (widen)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4392 (narrow-to-region from to))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4393 (goto-char (point-min))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4394
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4395 (if (re-search-forward
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
4396 "@\\(\\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
4397 (setq alist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4398 (list
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4399 (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
4400 (cons "&key" (reftex-match-string 2)))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4401 (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
4402 (setq key (downcase (reftex-match-string 1)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4403 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4404 ((= (following-char) ?{)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4405 (forward-char 1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4406 (setq start (point))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4407 (condition-case nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4408 (up-list 1)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4409 (error nil)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4410 ((= (following-char) ?\")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4411 (forward-char 1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4412 (setq start (point))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4413 (while (and (search-forward "\"" nil t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4414 (= ?\\ (char-after (- (point) 2))))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4415 (t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4416 (setq start (point))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4417 (re-search-forward "[ \t]*[\n\r,}]" nil 1)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4418 (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
4419 ;; remove extra whitespace
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4420 (while (string-match "[\n\t\r]\\|[ \t][ \t]+" field)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4421 (setq field (replace-match " " nil t field)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4422 ;; remove leading garbage
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4423 (if (string-match "^[ \t{]+" field)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4424 (setq field (replace-match "" nil t field)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4425 ;; remove trailing garbage
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4426 (if (string-match "[ \t}]+$" field)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4427 (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
4428 (push (cons key field) alist))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4429 alist))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4430
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4431 (defun reftex-get-bib-field (fieldname entry &optional format)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4432 ;; 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
4433 (let ((cell (assoc fieldname entry)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4434 (if cell
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4435 (if format
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4436 (format format (cdr cell))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4437 (cdr cell))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4438 "")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4439
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4440 (defun reftex-format-bib-entry (entry)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4441 ;; Format a BibTeX ENTRY so that it is nice to look at
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4442 (let*
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4443 ((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
4444 (authors (mapconcat 'identity auth-list ", "))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4445 (year (reftex-get-bib-field "year" entry))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4446 (title (reftex-get-bib-field "title" entry))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4447 (type (reftex-get-bib-field "&type" entry))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4448 (key (reftex-get-bib-field "&key" entry))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4449 (extra
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4450 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4451 ((equal type "article")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4452 (concat (reftex-get-bib-field "journal" entry) " "
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4453 (reftex-get-bib-field "volume" entry) ", "
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4454 (reftex-get-bib-field "pages" entry)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4455 ((equal type "book")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4456 (concat "book (" (reftex-get-bib-field "publisher" entry) ")"))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4457 ((equal type "phdthesis")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4458 (concat "PhD: " (reftex-get-bib-field "school" entry)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4459 ((equal type "mastersthesis")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4460 (concat "Master: " (reftex-get-bib-field "school" entry)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4461 ((equal type "inbook")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4462 (concat "Chap: " (reftex-get-bib-field "chapter" entry)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4463 ", pp. " (reftex-get-bib-field "pages" entry)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4464 ((or (equal type "conference")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4465 (equal type "incollection")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4466 (equal type "inproceedings"))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4467 (reftex-get-bib-field "booktitle" entry "in: %s"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4468 (t ""))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4469 (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
4470 (when (reftex-use-fonts)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4471 (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
4472 (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
4473 'font-lock-constant-face
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4474 'font-lock-reference-face)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4475 key)
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4476 (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
4477 authors)
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4478 (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
4479 year)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4480 (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
4481 title)
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4482 (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
4483 extra))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4484 (concat key "\n " authors " " year " " extra "\n " title "\n\n")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4485
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4486 (defun reftex-parse-bibitem (item)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4487 ;; Parse a \bibitem entry
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4488 (let ((key "") (text ""))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4489 (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
4490 (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
4491 text (match-string 2 item)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4492 ;; 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
4493 (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
4494 (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
4495 (if (string-match "\\`[ \t]+" text)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4496 (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
4497 (list
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4498 (cons "&key" key)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4499 (cons "&text" text)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4500 (cons "&entry" (concat key " " text)))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4501
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4502 (defun reftex-format-bibitem (item)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4503 ;; 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
4504 (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
4505 (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
4506 (lines nil))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4507
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4508 ;; 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
4509 (while (and (> (length text) 70)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4510 (string-match " " (substring text 60)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4511 (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
4512 (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
4513 (push text lines)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4514 (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
4515
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4516 (when (reftex-use-fonts)
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4517 (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
4518 (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
4519
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4520 ;; Make a citation
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4521
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4522 ;;;###autoload
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4523 (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
4524 "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
4525 After prompting for a regular expression, scans the buffers with
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4526 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
4527 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
4528 to `reftex-cite-format' and inserted into the buffer.
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
4529
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4530 If NO-INSERT is non-nil, nothing is inserted, only the selected key returned.
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
4531
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
4532 When called with one or two `C-u' prefixes, first rescans the document.
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
4533 When called with a numeric prefix, make that many citations. When
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
4534 called with point inside the braces of a `\cite' command, it will
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
4535 add another key, ignoring the value of `reftex-cite-format'.
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
4536
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
4537 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
4538 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
4539 While entering the regexp, completion on knows citation keys is possible.
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
4540 `=' is a good regular expression to match all entries in all files."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4541
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4542 (interactive)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4543
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4544 ;; check for recursive edit
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4545 (reftex-check-recursive-edit)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4546
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4547 ;; 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
4548 ;; 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
4549
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4550 (when reftex-mode
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4551 (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
4552
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4553 ;; Call reftex-do-citation, but protected
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4554 (unwind-protect
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4555 (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
4556 (reftex-kill-temporary-buffers)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4557
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4558 (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
4559 ;; 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
4560
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4561 (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
4562 (docstruct-symbol reftex-docstruct-symbol)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4563 (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
4564 (insert-entries selected-entries)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4565 entry string cite-view)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4566
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4567 (unless selected-entries (error "Quit"))
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 (if (stringp selected-entries)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4570 ;; Nonexistent entry
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4571 (setq selected-entries nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4572 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
4573 (cons "&key" selected-entries))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4574 ;; 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
4575 (setq cite-view t))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4576
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4577 (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
4578 ;; 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
4579 (pop selected-entries)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4580 (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
4581 (setq insert-entries
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4582 (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
4583
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4584 (unless no-insert
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4585
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4586 ;; 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
4587 (message "Formatting...")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4588
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4589 (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
4590 ;; 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
4591 (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
4592 (funcall reftex-format-cite-function
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4593 (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
4594 format)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4595 (reftex-format-citation entry format)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4596 (insert string))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4597
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4598 ;; Reposition cursor?
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4599 (when (string-match "\\?" string)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4600 (search-backward "?")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4601 (delete-char 1))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4602
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4603 ;; 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
4604 (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
4605 (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
4606 reftex-plug-into-AUCTeX)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4607 (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
4608
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4609 ;; 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
4610 (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
4611 (mapcar (lambda (entry)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4612 (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
4613 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 (message ""))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4616
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4617 (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
4618 (reftex-kill-buffer "*RefTeX Select*")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4619
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4620 ;; 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
4621 (when (integerp arg)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4622 (if (> arg 1)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4623 (progn
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4624 (skip-chars-backward "}")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4625 (decf arg)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4626 (reftex-do-citation arg))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4627 (forward-char 1)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4628
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4629 ;; Return the citation key
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4630 (car (car selected-entries))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4631
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4632 (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
4633 ;; 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
4634 ;; 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
4635 (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
4636 (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
4637 key format)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4638 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4639 (no-insert
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4640 ;; 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
4641 (setq format "%l"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4642
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4643 ((and (stringp macro)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4644 (string-match "\\`\\\\cite\\|cite\\'" macro))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4645 ;; 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
4646 (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
4647 (setq format
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4648 (concat
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4649 (if (member (preceding-char) '(?\{ ?,)) "" ",")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4650 "%l"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4651 (if (member (following-char) '(?\} ?,)) "" ",")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4652 (setq format "%l")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4653 (t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4654 ;; Figure out the correct format
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4655 (setq format
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4656 (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
4657 (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
4658 (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
4659 cite-format-value))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4660 (when (listp format)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4661 (setq key
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4662 (reftex-select-with-char
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4663 "" (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
4664 (mapconcat
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4665 (lambda (x)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4666 (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
4667 (if (> (car x) 31) " " "")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4668 (cdr x)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4669 format "\n"))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4670 (if (assq key format)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4671 (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
4672 (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
4673 format))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4674
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4675 (defun reftex-get-cite-format ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4676 ;; 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
4677 ;; 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
4678 (if (and reftex-docstruct-symbol
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4679 (symbolp reftex-docstruct-symbol)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4680 (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
4681 (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
4682 reftex-cite-format))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4683
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4684 (defun reftex-offer-bib-menu ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4685 ;; 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
4686
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4687 (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
4688 (while
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4689 (not
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4690 (catch 'done
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4691 ;; Scan bibtex files
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4692 (setq found-list
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4693 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4694 ((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
4695 ;; using BibTeX database files.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4696 (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
4697 ((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
4698 ;; using thebibliography environment.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4699 (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
4700 (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
4701 (reftex-default-bibliography
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4702 (message "Using default bibliography")
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
4703 (reftex-extract-bib-entries (reftex-default-bibliography)))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4704 (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
4705
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4706 (unless found-list
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4707 (error "Sorry, no matches found"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4708
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4709 ;; Remember where we came from
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4710 (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
4711 (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
4712
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4713 ;; Offer selection
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4714 (save-window-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4715 (delete-other-windows)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4716 (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
4717 (reftex-kill-buffer "*RefTeX Select*")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4718 (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
4719 (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
4720 (reftex-select-bib-mode))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4721 (let ((buffer-read-only nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4722 (erase-buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4723 (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
4724 (setq buffer-read-only t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4725 (if (= 0 (buffer-size))
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
4726 (error "No matches found"))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4727 (setq truncate-lines t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4728 (goto-char 1)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4729 (while t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4730 (setq rtn
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4731 (reftex-select-item
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4732 reftex-citation-prompt
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4733 reftex-citation-help
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4734 reftex-select-bib-map
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4735 nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4736 'reftex-bibtex-selection-callback nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4737 (setq key (car rtn)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4738 data (nth 1 rtn))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4739 (unless key (throw 'done t))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4740 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4741 ((eq key ?g)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4742 ;; Start over
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4743 (throw 'done nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4744 ((eq key ?r)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4745 ;; Restrict with new regular expression
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4746 (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
4747 (let ((buffer-read-only nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4748 (erase-buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4749 (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
4750 (goto-char 1))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4751 ((eq key ?A)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
4752 (debug)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4753 ;; Take all
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4754 (setq selected-entries found-list)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4755 (throw 'done t))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4756 ((eq key ?a)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4757 ;; Take all
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4758 (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
4759 (throw 'done t))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4760 ((or (eq key ?\C-m)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4761 (eq key 'return))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4762 ;; Take selected
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4763 (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
4764 (throw 'done t))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4765 ((stringp key)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4766 ;; Got this one with completion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4767 (setq selected-entries key)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4768 (throw 'done t))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4769 (t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4770 (ding))))))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4771 selected-entries))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4772
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4773 (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
4774 ;; 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
4775 (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
4776 "RegExp [ && RegExp...]: "
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4777 nil 'reftex-cite-regexp-hist)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4778 "[ \t]*&&[ \t]*"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4779 (found-list-r found-list)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4780 re)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4781 (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
4782 (setq found-list-r
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4783 (delq nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4784 (mapcar
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4785 (lambda (x)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4786 (if (string-match
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4787 re (cdr (assoc "&entry" x)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4788 x
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4789 nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4790 found-list-r))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4791 (if found-list-r
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4792 found-list-r
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4793 (ding)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4794 found-list)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4795
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4796 (defun reftex-insert-bib-matches (list)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4797 ;; 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
4798 (let ((mouse-face
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4799 (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
4800 reftex-mouse-selected-face
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4801 nil))
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4802 tmp len)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4803 (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4804 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4805 (lambda (x)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4806 (setq tmp (cdr (assoc "&formatted" x))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4807 len (length tmp))
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
4808 (put-text-property 0 len :data x tmp)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4809 (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
4810 (insert tmp)))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4811 list))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4812 (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
4813
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4814 (defun reftex-format-names (namelist n)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4815 (let (last (len (length namelist)))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4816 (cond
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4817 ((< len 1) "")
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4818 ((= 1 len) (car namelist))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4819 ((> 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
4820 (t
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4821 (setq n (min len n)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4822 last (nth (1- n) namelist))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4823 (setcdr (nthcdr (- n 2) namelist) nil)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4824 (concat
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4825 (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
4826 (nth 1 reftex-cite-punctuation)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4827 last)))))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4828
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4829 (defun reftex-format-citation (entry format)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4830 ;; 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
4831
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4832 (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
4833
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4834 (if (and reftex-comment-citations
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4835 (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
4836 (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
4837
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4838 (while (string-match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4839 "\\(\\`\\|[^%]\\)\\(\\(%\\([0-9]*\\)\\([a-zA-Z]\\)\\)[.,;: ]*\\)"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4840 format)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4841 (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
4842 (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
4843 rpl b e)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4844 (save-match-data
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4845 (setq rpl
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4846 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4847 ((= l ?l) (concat
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4848 (reftex-get-bib-field "&key" entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4849 (if reftex-comment-citations
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4850 reftex-cite-comment-format
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4851 "")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4852 ((= l ?a) (reftex-format-names
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4853 (reftex-get-bib-names "author" entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4854 (or n 2)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4855 ((= 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
4856 ((= 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
4857 ((= l ?B) (reftex-abbreviate-title
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4858 (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
4859 ((= 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
4860 ((= 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
4861 ((= l ?e) (reftex-format-names
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4862 (reftex-get-bib-names "editor" entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4863 (or n 2)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4864 ((= 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
4865 ((= 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
4866 ((= 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
4867 ((= 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
4868 ((= 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
4869 ((= 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
4870 ((= 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
4871 ((= 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
4872 ((= 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
4873 ((= l ?P) (car (split-string
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4874 (reftex-get-bib-field "pages" entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4875 "[- .]+")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4876 ((= 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
4877 ((= 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
4878 ((= 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
4879 ((= 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
4880 ((= l ?T) (reftex-abbreviate-title
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4881 (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
4882 ((= 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
4883 ((= 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
4884
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4885 (if (string= rpl "")
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4886 (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
4887 (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
4888 (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
4889 (while (string-match "%%" format)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4890 (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
4891 (while (string-match "[ ,.;:]*%<" format)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4892 (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
4893 format)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4894
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4895 (defun reftex-bibtex-selection-callback (data ignore no-revisit)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4896 ;; 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
4897 ;; 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
4898 ;; recommended for follow mode. It works OK for individual lookups.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4899 (let ((win (selected-window))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4900 (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
4901 bibfile-list item tmp)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4902
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4903 (catch 'exit
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4904 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4905 (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
4906 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4907 ((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
4908 (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
4909 ((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
4910 (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
4911 item t))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4912 (reftex-default-bibliography
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
4913 (setq bibfile-list (reftex-default-bibliography)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4914 (t (ding) (throw 'exit))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4915
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4916 (when no-revisit
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4917 (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
4918
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4919 (condition-case nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4920 (reftex-pop-to-bibtex-entry
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4921 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
4922 (error (ding))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4923
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4924 (select-window win)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4925
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
4926 ;;; =========================================================================
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4927 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4928 ;;; Here is the routine used for selection
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4929
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4930 ;; Marker for return point from recursive edit
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4931 (defvar reftex-recursive-edit-marker (make-marker))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4932
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4933 (defvar reftex-last-data nil)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4934 (defvar reftex-last-line nil)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4935
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4936 (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
4937 ;; 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
4938 ;; message if so.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4939 (if (marker-position reftex-recursive-edit-marker)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4940 (error
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4941 (substitute-command-keys
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
4942 "In unfinished selection process. Finish, or abort with \\[abort-recursive-edit]"))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4943
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4944 (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
4945 &optional offset
21115
fea2f6a2818d 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21114
diff changeset
4946 call-back cb-flag)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4947 ;; 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
4948 ;; 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
4949 ;; selected.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4950 ;; 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
4951 ;; selection commands.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4952 ;; 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
4953 ;; 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
4954 ;; 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
4955 ;; 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
4956 ;; of the element.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4957 ;; 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
4958
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
4959 (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
4960
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4961 (setq ev
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4962 (catch 'myexit
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4963 (save-window-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4964 (setq truncate-lines t)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4965
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4966 ;; Find a good starting point
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
4967 (reftex-find-start-point
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
4968 (point-min) offset reftex-last-data reftex-last-line)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4969 (beginning-of-line 1)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4970 (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
4971
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4972 (unwind-protect
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4973 (progn
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4974 (use-local-map keymap)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4975 (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
4976 (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
4977 (princ prompt)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4978 (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
4979 ;; 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
4980 (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
4981 (recursive-edit))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4982
21075
0c95fb73e090 1998-03-06 Carsten Dominik <cd@delysid.gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21002
diff changeset
4983 (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
4984 (save-excursion
0c95fb73e090 1998-03-06 Carsten Dominik <cd@delysid.gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21002
diff changeset
4985 (set-buffer selection-buffer)
0c95fb73e090 1998-03-06 Carsten Dominik <cd@delysid.gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21002
diff changeset
4986 (use-local-map nil)
0c95fb73e090 1998-03-06 Carsten Dominik <cd@delysid.gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21002
diff changeset
4987 (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
4988 (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
4989 '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
4990
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4991 (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
4992 (+ (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
4993 (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
4994 (reftex-kill-buffer "*RefTeX Help*")
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
4995 (setq reftex-callback-fwd (not reftex-callback-fwd)) ;; ;-)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4996 (message "")
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4997 (list ev data last-data)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4998
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4999 ;; 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
5000 ;; 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
5001
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5002 (defvar found-list)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5003 (defvar cb-flag)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5004 (defvar data)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5005 (defvar prompt)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5006 (defvar last-data)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5007 (defvar call-back)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5008 (defvar help-string)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5009 (defvar varioref)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5010
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5011 ;; The selection commands
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5012
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5013 (defun reftex-select-pre-command-hook ()
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5014 (reftex-unhighlight 1)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5015 (reftex-unhighlight 0))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5016
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5017 (defun reftex-select-post-command-hook ()
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5018 (let (b e)
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5019 (setq data (get-text-property (point) :data))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5020 (setq last-data (or data last-data))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5021
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5022 (when (and data cb-flag
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5023 (not (equal reftex-last-follow-point (point))))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5024 (setq reftex-last-follow-point (point))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5025 (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
5026 (not reftex-revisit-to-follow)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5027 (if data
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5028 (setq b (or (previous-single-property-change
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5029 (1+ (point)) :data)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5030 (point-min))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5031 e (or (next-single-property-change
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5032 (point) :data)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5033 (point-max)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5034 (setq b (point) e (point)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5035 (and (memq reftex-highlight-selection '(cursor both))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5036 (reftex-highlight 1 b e))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5037 (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
5038 (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
5039 (recenter '(4)))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5040 (unless (current-message)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5041 (princ prompt))))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5042
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5043 (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
5044 "Move to next selectable item."
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5045 (interactive "p")
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5046 (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
5047 (or (eobp) (forward-char 1))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5048 (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
5049 (beginning-of-line 1))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5050 (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
5051 "Move to previous selectable item."
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5052 (interactive "p")
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5053 (setq reftex-callback-fwd nil)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5054 (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
5055 (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
5056 "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
5057 (interactive "p")
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5058 (end-of-line)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5059 (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
5060 (beginning-of-line))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5061 (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
5062 "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
5063 (interactive "p")
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5064 (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
5065 (defun reftex-select-quit ()
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5066 "Abort selection process."
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5067 (interactive)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5068 (throw 'myexit nil))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5069 (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
5070 "Abort selection process."
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5071 (interactive)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5072 (throw 'exit t))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5073 (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
5074 "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
5075 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5076 (let (pos)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5077 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5078 ((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
5079 reftex-last-data
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5080 (setq pos (text-property-any (point-min) (point-max)
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5081 :data reftex-last-data)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5082 (goto-char pos))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5083 ((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
5084 (integerp reftex-last-line))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5085 (goto-line reftex-last-line))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5086 (t (ding)))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5087 (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
5088 "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
5089 (interactive)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5090 (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
5091 (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
5092 (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
5093 "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
5094 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5095 (if (string= varioref "\\ref")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5096 (setq varioref "\\vref")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5097 (setq varioref "\\ref"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5098 (force-mode-line-update))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5099 (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
5100 "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
5101 (interactive)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5102 (let ((this-window (selected-window)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5103 (unwind-protect
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5104 (progn
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5105 (switch-to-buffer-other-window
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5106 (marker-buffer reftex-select-return-marker))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5107 (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
5108 (recenter '(4)))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5109 (select-window this-window))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5110 (defun reftex-select-callback ()
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5111 "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
5112 (interactive)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5113 (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
5114 (defun reftex-select-accept ()
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5115 "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
5116 (interactive)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5117 (throw 'myexit 'return))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5118 (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
5119 "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
5120 (interactive "e")
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5121 (mouse-set-point ev)
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5122 (setq data (get-text-property (point) :data))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5123 (setq last-data (or data last-data))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5124 (throw 'myexit 'return))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5125 (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
5126 "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
5127 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5128 (let ((label (completing-read
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5129 "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
5130 nil nil reftex-prefix)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5131 (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
5132 (throw 'myexit label))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5133 (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
5134 "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
5135 (interactive)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5136 (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
5137 (entry (assoc key found-list)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5138 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5139 ((or (null key) (equal key "")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5140 (entry
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5141 (setq data entry)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5142 (setq last-data data)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5143 (throw 'myexit 'return))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5144 (t (throw 'myexit key)))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5145 (defun reftex-select-help ()
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5146 "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
5147 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5148 (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
5149 (princ help-string))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5150 (reftex-enlarge-to-fit "*RefTeX Help*" t))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5151
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5152 ;;; =========================================================================
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5153 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5154 ;;; View cross references
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5155
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5156 (defun reftex-view-crossref (&optional arg auto-how)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5157 "View cross reference of macro at point. Point must be on the KEY
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5158 argument. When at at `\ref' macro, show corresponding `\label'
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5159 definition, also in external documents (`xr'). When on a label, show
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5160 a locations where KEY is referenced. Subsequent calls find additional
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5161 locations. When on a `\cite', show the associated `\bibitem' macro or
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5162 the BibTeX database entry. When on a `\bibitem', show a `\cite' macro
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5163 which uses this KEY. When on an `\index', show other locations marked
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5164 by the same index entry.
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5165 To define additional cross referencing items, use the option
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5166 `reftex-view-crossref-extra'. See also `reftex-view-crossref-from-bibtex'.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5167 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
5168 With argument 2, select the window showing the cross reference.
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5169 AUTO-HOW is only for the automatic crossref display and is handed through
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5170 to the functions `reftex-view-cr-cite' and `reftex-view-cr-ref'."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5171
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5172 (interactive "P")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5173 ;; 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
5174 (let* ((macro (car (reftex-what-macro 1)))
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5175 (key (reftex-this-word "^{}%\n\r,"))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5176 dw)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5177
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5178 (if (or (null macro) (reftex-in-comment))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5179 (error "Not on a crossref macro argument"))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5180
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5181 (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
5182
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5183 (cond
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5184 ((string-match "\\`\\\\cite\\|cite\\*?\\'" macro)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5185 ;; A citation macro: search for bibitems or BibTeX entries
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5186 (setq dw (reftex-view-cr-cite arg key auto-how)))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5187 ((string-match "\\`\\\\ref\\|ref\\*?\\'" macro)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5188 ;; A reference macro: search for labels
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5189 (setq dw (reftex-view-cr-ref arg key auto-how)))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5190 (auto-how nil) ;; No further action for automatic display (speed)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5191 ((or (equal macro "\\label")
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5192 (member macro reftex-macros-with-labels))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5193 ;; A label macro: search for reference macros
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5194 (reftex-access-scan-info arg)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5195 (setq dw (reftex-view-regexp-match
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5196 (format reftex-find-reference-format (regexp-quote key))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5197 3 nil nil)))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5198 ((equal macro "\\bibitem")
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5199 ;; A bibitem macro: search for citations
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5200 (reftex-access-scan-info arg)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5201 (setq dw (reftex-view-regexp-match
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5202 (format reftex-find-citation-regexp-format (regexp-quote key))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5203 3 nil nil)))
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5204 (t
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5205 (reftex-access-scan-info arg)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5206 (catch 'exit
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5207 (let ((list reftex-view-crossref-extra)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5208 entry mre action group)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5209 (while (setq entry (pop list))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5210 (setq mre (car entry)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5211 action (nth 1 entry)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5212 group (nth 2 entry))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5213 (when (string-match mre macro)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5214 (setq dw (reftex-view-regexp-match
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5215 (format action key) group nil nil))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5216 (throw 'exit t))))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5217 (error "Not on a crossref macro argument"))))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5218 (if (and (eq arg 2) (windowp dw)) (select-window dw))))
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5219
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5220 (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
5221 ;; 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
5222 ;; 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
5223 ;; 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
5224 ;; 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
5225
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5226 ;; 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
5227 (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
5228
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5229 (if (eq how 'tmp-window)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5230 ;; Remember the window configuration
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5231 (put 'reftex-auto-view-crossref 'last-window-conf
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5232 (current-window-configuration)))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5233
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5234 (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
5235 ;; 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
5236 (cond
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5237 ((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
5238 (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
5239 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
5240 ((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
5241 (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
5242 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
5243 (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
5244 (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
5245 (setq item nil
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5246 files (reftex-default-bibliography)))
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5247 (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
5248 (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
5249
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5250 (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
5251 ;; 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
5252 (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
5253 ;; 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
5254 (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
5255 ;; Normal display
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5256 (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
5257 ;; 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
5258 (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
5259 (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
5260 (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
5261 (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
5262 (error "")))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5263 ;; 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
5264 (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
5265 (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
5266 (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
5267 (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
5268 (recenter 0))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5269 ;; Arrange restoration
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5270 (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
5271
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5272 ;; 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
5273 (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
5274 (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
5275 (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
5276 (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
5277 (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
5278 (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
5279
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5280 (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
5281 ;; 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
5282 ;; 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
5283 ;; 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
5284 ;; 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
5285
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5286 ;; 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
5287 (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
5288
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5289 (if (eq how 'tmp-window)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5290 ;; Remember the window configuration
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5291 (put 'reftex-auto-view-crossref 'last-window-conf
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5292 (current-window-configuration)))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5293
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5294 (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
5295 (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
5296 (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
5297 (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
5298
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5299 (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
5300 ;; 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
5301 (save-excursion
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5302 (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
5303 (set-buffer
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5304 (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
5305 (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
5306 xr-data))))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5307 (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
5308 (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
5309 (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
5310 (setq entry
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5311 (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
5312 (if (eq how 'echo)
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5313 ;; Display 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
5314 (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
5315 (let ((window-conf (current-window-configuration)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5316 (condition-case nil
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5317 (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
5318 (error (set-window-configuration window-conf)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5319 (message "ref: Label %s not found" label)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5320 (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
5321 (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
5322
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5323 (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
5324 ;; 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
5325 (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
5326 (recenter '(4))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5327 (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
5328 (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
5329 (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
5330 (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
5331 (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
5332 (select-window pop-win)))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5333
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5334 (defun reftex-mouse-view-crossref (ev)
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
5335 "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
5336 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
5337 If it is a \\cite, show the BibTeX database entry.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5338 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
5339 With argument, actually select the window showing the cross reference."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5340 (interactive "e")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5341 (mouse-set-point ev)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5342 (reftex-view-crossref current-prefix-arg))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5343
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5344 (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
5345 "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
5346
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5347 (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
5348 ;; 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
5349 ;; 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
5350 ;; 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
5351 (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
5352 ;; 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
5353 (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
5354 ;; 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
5355 (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
5356 reftex-mouse-view-crossref)))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5357 ;; 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
5358 ;; FIXME: Can fail with backslash in comment
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5359 (save-excursion
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5360 (search-backward "\\" nil t)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5361 (looking-at "\\\\[a-zA-Z]*\\(cite\\|ref\\)"))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5362
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5363 (condition-case nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5364 (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
5365 (cond
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5366 ((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
5367 (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
5368 ((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
5369 (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
5370 (t nil)))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5371 (error nil))))
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5372
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5373 (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
5374 (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
5375 (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
5376 (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
5377
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5378 (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
5379 ;; 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
5380 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5381 ((null docstruct)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5382 (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
5383 ((null entry)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5384 (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
5385 (t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5386 (when (stringp (nth 2 entry))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5387 (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
5388 (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
5389 (when buf
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5390 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5391 (set-buffer buf)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5392 (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
5393
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5394 (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
5395 ;; 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
5396 (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
5397 (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
5398 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
5399
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5400 (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
5401 ;; 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
5402 (setq string (cdr cache-entry))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5403
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5404 ;; 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
5405 (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
5406 (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
5407
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5408 (setq entry
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5409 (condition-case nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5410 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5411 (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
5412 (error
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5413 (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
5414 (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
5415 (message (substitute-command-keys
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5416 (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
5417 nil)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5418 (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
5419 (if item
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5420 (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
5421 (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
5422 (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
5423 reftex-docstruct-symbol)))))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5424 (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
5425 (message "cite: %s" string))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5426 (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
5427 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5428 (set-buffer buf)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5429 (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
5430
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5431 (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
5432 ;; 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
5433 (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
5434 (string
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5435 (let* ((reftex-cite-punctuation '(" " " & " " etal.")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5436 (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
5437 (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
5438 (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
5439 (unless cache
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5440 ;; 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
5441 (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
5442 (symbol-value docstruct-symbol))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5443 (when reftex-cache-cite-echo
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5444 (setq key (copy-sequence key))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5445 (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
5446 (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
5447 (if cache-entry
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5448 (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
5449 (setcdr cache-entry string)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5450 (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
5451 (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
5452 (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
5453 string))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5454
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5455 (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
5456 "*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
5457 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
5458
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5459 (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
5460 "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
5461 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
5462 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
5463 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5464 (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
5465 (progn
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5466 (if (featurep 'xemacs)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5467 (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
5468 (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
5469 (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
5470 (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
5471 (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
5472 (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
5473 (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
5474 (if (featurep 'xemacs)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5475 (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
5476 (start-itimer "RefTeX Idle Timer"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5477 'reftex-view-crossref-when-idle
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5478 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
5479 (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
5480 t)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5481 (run-with-idle-timer
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5482 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
5483 (unless reftex-auto-view-crossref
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5484 (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
5485 (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
5486
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5487 (defun reftex-start-itimer-once ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5488 (and reftex-mode
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5489 (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
5490 (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
5491 (start-itimer "RefTeX Idle Timer"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5492 'reftex-view-crossref-when-idle
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5493 reftex-idle-time nil t))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5494
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5495 (defun reftex-view-crossref-from-bibtex (&optional arg)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5496 "View location in a LaTeX document which cites the BibTeX entry at point.
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5497 Since BibTeX files can be used by many LaTeX documents, this function
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5498 promps upon first use for a buffer in RefTeX mode. To reset this
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5499 link to a document, call the function with with a prefix arg.
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5500 Calling this function several times find successive citation locations."
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5501 (interactive "P")
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5502 (when arg
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5503 ;; Break connection to reference buffer
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5504 (remprop 'reftex-bibtex-view-cite-locations :ref-buffer))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5505 (let ((ref-buffer (get 'reftex-bibtex-view-cite-locations :ref-buffer)))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5506 ;; Establish connection to reference buffer
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5507 (unless ref-buffer
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5508 (setq ref-buffer
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5509 (save-excursion
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5510 (completing-read
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5511 "Reference buffer: "
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5512 (delq nil
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5513 (mapcar
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5514 (lambda (b)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5515 (set-buffer b)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5516 (if reftex-mode (list (buffer-name b)) nil))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5517 (buffer-list)))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5518 nil t)))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5519 (put 'reftex-bibtex-view-cite-locations :ref-buffer ref-buffer))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5520 ;; Search for citations
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5521 (bibtex-beginning-of-entry)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5522 (if (looking-at
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5523 "@[a-zA-Z]+[ \t\n\r]*[{(][ \t\n\r]*\\([^, \t\r\n}]+\\)")
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5524 (progn
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5525 (goto-char (match-beginning 1))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5526 (reftex-view-regexp-match
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5527 (format reftex-find-citation-regexp-format
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5528 (regexp-quote (match-string 1)))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5529 3 arg ref-buffer))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5530 (error "Cannot find citation key in BibTeX entry"))))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5531
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5532 (defun reftex-view-regexp-match (re &optional highlight-group new ref-buffer)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5533 ;; Search for RE in current document or in the document of REF-BUFFER.
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5534 ;; Continue the search, if the same re was searched last.
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5535 ;; Highlight the group HIGHLIGHT-GROUP of the match.
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5536 ;; When NEW is non-nil, start a new search regardless.
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5537 ;; Match point is displayed in another window.
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5538 ;; Upon success, returns the window which displays the match.
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5539
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5540 ;;; Decide if new search or continued search
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5541 (let* ((oldprop (get 'reftex-view-regexp-match :props))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5542 (newprop (list (current-buffer) re))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5543 (cont (and (not new) (equal oldprop newprop)))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5544 (cnt (if cont (get 'reftex-view-regexp-match :cnt) 0))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5545 (current-window (selected-window))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5546 (window-conf (current-window-configuration))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5547 match pop-window)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5548 (switch-to-buffer-other-window (or ref-buffer (current-buffer)))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5549 ;; Search
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5550 (condition-case nil
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5551 (if cont
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5552 (setq match (reftex-global-search-continue))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5553 (reftex-access-scan-info)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5554 (setq match (reftex-global-search re (reftex-all-document-files))))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5555 (error nil))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5556 ;; Evaluate the match.
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5557 (if match
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5558 (progn
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5559 (put 'reftex-view-regexp-match :props newprop)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5560 (put 'reftex-view-regexp-match :cnt (incf cnt))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5561 (reftex-highlight 0 (match-beginning highlight-group)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5562 (match-end highlight-group))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5563 (add-hook 'pre-command-hook 'reftex-highlight-shall-die)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5564 (setq pop-window (selected-window)))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5565 (remprop 'reftex-view-regexp-match :props)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5566 (or cont (set-window-configuration window-conf)))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5567 (select-window current-window)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5568 (if match
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5569 (progn
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5570 (message "Match Nr. %s" cnt)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5571 pop-window)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5572 (if cont
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5573 (error "No further matches (total number of matches: %d)" cnt)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5574 (error "No matches")))))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5575
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5576 (defvar reftex-global-search-marker (make-marker))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5577 (defun reftex-global-search (regexp file-list)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5578 ;; Start a search for REGEXP in all files of FILE-LIST
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5579 (put 'reftex-global-search :file-list file-list)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5580 (put 'reftex-global-search :regexp regexp)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5581 (move-marker reftex-global-search-marker nil)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5582 (reftex-global-search-continue))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5583
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5584 (defun reftex-global-search-continue ()
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5585 ;; Continue a global search started with `reftex-global-search'
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5586 (unless (get 'reftex-global-search :file-list)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5587 (error "No global search to continue"))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5588 (let* ((file-list (get 'reftex-global-search :file-list))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5589 (regexp (get 'reftex-global-search :regexp))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5590 (buf (or (marker-buffer reftex-global-search-marker)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5591 (reftex-get-file-buffer-force (car file-list))))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5592 (pos (or (marker-position reftex-global-search-marker) 1))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5593 file)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5594 ;; Take up starting position
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5595 (unless buf (error "No such buffer %s" buf))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5596 (switch-to-buffer buf)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5597 (widen)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5598 (goto-char pos)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5599 ;; Search and switch file if necessary
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5600 (if (catch 'exit
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5601 (while t
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5602 (when (re-search-forward regexp nil t)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5603 (move-marker reftex-global-search-marker (point))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5604 (throw 'exit t))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5605 ;; No match - goto next file
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5606 (pop file-list)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5607 (or file-list (throw 'exit nil))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5608 (setq file (car file-list)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5609 buf (reftex-get-file-buffer-force file))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5610 (unless buf (error "Cannot access file %s" file))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5611 (put 'reftex-global-search :file-list file-list)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5612 (switch-to-buffer buf)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5613 (widen)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5614 (goto-char 1)))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5615 t
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5616 (move-marker reftex-global-search-marker nil)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5617 (error "All files processed"))))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
5618
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5619 ;;; =========================================================================
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5620 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5621 ;;; Functions that check out the surroundings
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5622
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5623 (defun reftex-what-macro (which &optional bound)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5624 ;; 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
5625 ;; 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
5626
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5627 ;; 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
5628 ;; If WHICH is 1, return innermost enclosing macro.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5629 ;; If WHICH is t, return list of all macros enclosing point.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5630 ;; 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
5631 ;; name of the first macro in this list found to enclose point.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5632 ;; 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
5633 ;; 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
5634 ;; like statement.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5635
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5636 ;; 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
5637 ;; 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
5638 ;; 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
5639 ;; considered an argument of macro \macro.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5640
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5641 (unless reftex-section-regexp (reftex-compile-variables))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5642 (catch 'exit
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5643 (if (null which) (throw 'exit nil))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5644 (let ((bound (or bound (save-excursion (re-search-backward
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5645 reftex-section-regexp nil 1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5646 (point))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5647 pos cmd-list cmd cnt cnt-opt entry)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5648 (save-restriction
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5649 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5650 (narrow-to-region (max 1 bound) (point-max))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5651 ;; move back out of the current parenthesis
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5652 (while (condition-case nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5653 (progn (up-list -1) t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5654 (error nil))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5655 (setq cnt 1 cnt-opt 0)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5656 ;; 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
5657 (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
5658 (condition-case nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5659 (progn (backward-sexp) t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5660 (error nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5661 (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
5662 (incf cnt))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5663 (setq pos (point))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5664 (when (and (or (= (following-char) ?\[)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5665 (= (following-char) ?\{))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5666 (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
5667 (setq cmd (reftex-match-string 0))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5668 (when (looking-at "\\\\begin{[^}]*}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5669 (setq cmd (reftex-match-string 0)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5670 cnt (1- cnt)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5671 ;; 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
5672 (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
5673 (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
5674 (setq cmd nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5675 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5676 ((null cmd))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5677 ((eq t which)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5678 (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
5679 ((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
5680 (throw 'exit (cons cmd (point))))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5681 (goto-char pos)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5682 (nreverse cmd-list)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5683
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5684 (defun reftex-what-environment (which &optional bound)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5685 ;; 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
5686 ;; 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
5687 ;; them.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5688
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5689 ;; 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
5690 ;; If WHICH is 1, return innermost enclosing environment.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5691 ;; If WHICH is t, return list of all environments enclosing point.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5692 ;; 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
5693 ;; 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
5694 ;; point.
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 ;; 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
5697 ;; 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
5698
23200
4750ba95a176 (reftex-view-crossref): Split up into several functions. No longer moves
Carsten Dominik <dominik@science.uva.nl>
parents: 22991
diff changeset
5699 (unless reftex-section-regexp (reftex-compile-variables))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5700 (catch 'exit
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5701 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5702 (if (null which) (throw 'exit nil))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5703 (let ((bound (or bound (save-excursion (re-search-backward
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5704 reftex-section-regexp nil 1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5705 (point))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5706 env-list end-list env)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5707 (while (re-search-backward "\\\\\\(begin\\|end\\){\\([^}]+\\)}"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5708 bound t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5709 (setq env (buffer-substring-no-properties
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5710 (match-beginning 2) (match-end 2)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5711 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5712 ((string= (match-string 1) "end")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5713 (add-to-list 'end-list env))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5714 ((member env end-list)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5715 (setq end-list (delete env end-list)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5716 ((eq t which)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5717 (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
5718 ((or (eq 1 which) (member env which))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5719 (throw 'exit (cons env (point))))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5720 (nreverse env-list)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5721
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5722 ;;; =========================================================================
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5723 ;;;
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5724 ;;; Finding files
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5725
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5726 (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
5727 "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
5728 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
5729 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
5730 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
5731 (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
5732 (extensions (cdr (assoc type reftex-file-extensions)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5733 (def-ext (car extensions))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5734 (ext-re (concat "\\("
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5735 (mapconcat 'regexp-quote extensions "\\|")
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5736 "\\)\\'"))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5737 (files (if (string-match ext-re file)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5738 (cons file nil)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5739 (cons (concat file def-ext) file)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5740 path old-path file1)
23344
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5741 (cond
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5742 ((file-name-absolute-p file)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5743 (setq file1
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5744 (or
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5745 (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
5746 (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
5747 ((and reftex-use-external-file-finders
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5748 (assoc type reftex-external-file-finders))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5749 (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
5750 (t
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5751 (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
5752 (setq path (reftex-access-search-path
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5753 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
5754 (if (or (null old-path)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5755 (not (eq old-path path)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5756 (setq old-path path
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5757 path (cons master-dir path)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5758 file1 (or (and (car files)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5759 (reftex-find-file-on-path
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5760 (car files) path master-dir))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5761 (and (cdr files)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5762 (reftex-find-file-on-path
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5763 (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
5764 (cond (file1 file1)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5765 (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
5766 (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
5767
23344
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5768 (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
5769 ;; Use external program to find FILE.
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5770 ;; 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
5771 ;; 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
5772 (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
5773 (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
5774 out)
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5775 (if (string-match "%f" prg)
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5776 (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
5777 (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
5778 (if (string-match "[ \t\n]+\\'" out)
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5779 (setq out (replace-match "" nil nil out)))
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5780 (cond ((equal out "") nil)
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5781 ((file-regular-p out) out)
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5782 (t nil))))
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5783
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5784 (defun reftex-process-string (program &rest args)
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5785 "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
5786 (with-output-to-string
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5787 (with-current-buffer standard-output
23344
608bc56ca20e (reftex-finding-files): New customize group.
Carsten Dominik <dominik@science.uva.nl>
parents: 23200
diff changeset
5788 (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
5789
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5790 (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
5791 ;; 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
5792 ;; 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
5793 ;; 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
5794 ;; 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
5795 ;; 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
5796 ;; 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
5797 ;; Returns the derived path.
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5798 (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
5799 (when (null (get pathvar 'status))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5800 ;; Get basic path
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5801 (set pathvar
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5802 (reftex-uniq
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5803 (reftex-parse-colon-path
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5804 (mapconcat
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5805 (lambda(x)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5806 (if (string-match "^!" x)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5807 (apply 'reftex-process-string
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5808 (split-string (substring x 1)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5809 (or (getenv x) x)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5810 ;; 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
5811 ;; (cdr (assoc type reftex-path-environment))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5812 ;; 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
5813 ;; 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
5814 (symbol-value (intern (concat "reftex-" type
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5815 "path-environment-variables")))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5816 path-separator))))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5817 (put pathvar 'status 'split)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5818 ;; 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
5819 (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
5820 (while (setq dir (pop path))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5821 (when (string= (substring dir -2) "//")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5822 (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
5823 (setq rec (or rec 'absolute))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5824 (setq rec 'relative))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5825 (put pathvar 'rec-type rec)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5826
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5827 (if recurse
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5828 ;; 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
5829 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5830 ((not (get pathvar 'rec-type))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5831 ;; 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
5832 (symbol-value pathvar))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5833 ((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
5834 (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
5835 (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
5836 ;; 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
5837 ;; 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
5838 ;; relative to new default directory
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5839 (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
5840 (put pathvar 'recursive-path
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5841 (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
5842 (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
5843 (get pathvar 'recursive-path))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5844 (t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5845 ;; 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
5846 (get pathvar 'recursive-path)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5847 ;; The simple path was requested
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5848 (symbol-value pathvar))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5849
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5850 (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
5851 ;; 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
5852 ;; 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
5853 (catch 'exit
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5854 (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
5855 (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
5856 (throw 'exit file)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5857 (throw 'exit nil)))
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5858 (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
5859 (while (setq dir (pop thepath))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5860 (when (string= (substring dir -2) "//")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5861 (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
5862 (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
5863 (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
5864 (throw 'exit file1)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5865 ;; No such file
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5866 nil)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5867
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5868 (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
5869 ;; 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
5870 ;; 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
5871 (mapcar
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5872 (lambda (dir)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5873 (if (string-match "\\(//+\\|/*!+\\)\\'" dir)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5874 (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
5875 (file-name-as-directory dir))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5876 (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
5877
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5878 (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
5879 ;; 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
5880 ;; 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
5881 (let (path1 dir recursive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5882 (while (setq dir (pop path))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5883 (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
5884 (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
5885 (if (and recursive
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5886 (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
5887 (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
5888 (if recursive
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5889 ;; Expand recursively
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5890 (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
5891 ;; Keep unchanged
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5892 (push dir path1)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5893 (nreverse path1)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5894
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5895 (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
5896 ;; 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
5897 (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
5898 (while (setq dir (pop path))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5899 (when (file-directory-p dir)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5900 (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
5901 (while (setq file (pop files))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5902 (if (file-directory-p file)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5903 (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
5904 (push dir path1)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5905 path1))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5906
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5907 (defun reftex-uniq (list)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5908 (let (new)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5909 (while list
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5910 (or (member (car list) new)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5911 (push (car list) new))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5912 (pop list))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5913 (nreverse new)))
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5914
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5915 ;;; =========================================================================
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5916 ;;;
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5917 ;;; Some generally useful functions
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5918
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5919 (defun reftex-no-props (string)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5920 ;; Return STRING with all text properties removed
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5921 (and (stringp string)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5922 (set-text-properties 0 (length string) nil string))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5923 string)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5924
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5925 (defun reftex-match-string (n)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5926 ;; Match string without properties
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5927 (when (match-beginning n)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5928 (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
5929
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5930 (defun reftex-kill-buffer (buffer)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5931 ;; 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
5932 (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
5933 (kill-buffer buffer)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5934
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5935 (defun reftex-erase-buffer (&optional buffer)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5936 ;; 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
5937 ;; This even erases read-only buffers.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5938 (cond
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5939 ((null buffer)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5940 ;; erase current buffer
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5941 (let ((buffer-read-only nil)) (erase-buffer)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5942 ((setq buffer (get-buffer buffer))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5943 ;; buffer exists
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5944 (save-excursion
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5945 (set-buffer buffer)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5946 (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
5947
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5948 (defun reftex-this-word (&optional class)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5949 ;; Grab the word around point.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5950 (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
5951 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5952 (buffer-substring-no-properties
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5953 (progn (skip-chars-backward class) (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5954 (progn (skip-chars-forward class) (point)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5955
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5956 (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
5957 ;; 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
5958 (let (rtn)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5959 (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
5960 (push (car list) rtn)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5961 (pop list))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5962 (nreverse rtn)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5963
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5964 (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
5965 ;; 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
5966 (let (rtn)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5967 (while list
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5968 (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
5969 (push (car list) rtn))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5970 (pop list))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5971 (nreverse rtn)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5972
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5973 (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
5974 ;; 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
5975 ;; 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
5976 ;; 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
5977 ;; On success, returns the association.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5978 (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
5979
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5980 (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
5981 (setq list (memq ass list))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5982 (memq elt list))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5983 (setq last-ass ass
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5984 list (cdr list)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5985 last-ass))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
5986
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5987 (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
5988 ;; Truncate STRING to NCOLS characters.
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5989 ;; 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
5990 ;; 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
5991 ;; 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
5992 (setq string
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5993 (if (<= (length string) ncols)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5994 string
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5995 (if ellipses
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5996 (concat (substring string 0 (- ncols 3)) "...")
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
5997 (substring string 0 ncols))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5998 (if padding
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5999 (format (format "%%-%ds" ncols) string)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6000 string))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6001
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6002 (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
6003 ;; 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
6004 ;; 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
6005 ;; 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
6006 (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
6007 (goto-char start)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6008 (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
6009 (setq match1 (match-data)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6010 (goto-char start)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6011 (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
6012 (setq match2 (match-data)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6013 (goto-char start)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6014 (setq match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6015 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6016 ((not match1) match2)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6017 ((not match2) match1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6018 ((< (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
6019 (t match2)))
21170
dbe101f49d57 (reftex-nearest-match): store-match-data => set-match-data.
Richard M. Stallman <rms@gnu.org>
parents: 21130
diff changeset
6020 (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
6021
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6022 (defun reftex-auto-mode-alist ()
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6023 ;; 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
6024 ;; Stolen from gnus nnheader.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6025 (let ((alist auto-mode-alist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6026 out)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6027 (while alist
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6028 (when (listp (cdr (car alist)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6029 (push (car alist) out))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6030 (pop alist))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6031 (nreverse out)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6032
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
6033 (defun reftex-window-height ()
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
6034 (if (fboundp 'window-displayed-height)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
6035 (window-displayed-height)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
6036 (window-height)))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
6037
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6038 (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
6039 ;; 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
6040 ;; 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
6041 (let* ((win1 (selected-window))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6042 (buf1 (current-buffer))
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
6043 (win2 (get-buffer-window buf2))) ;; Only on current frame.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6044 (when win2
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6045 (select-window win2)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6046 (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
6047 (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
6048 (enlarge-window (1+ (- (count-lines 1 (point-max))
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
6049 (reftex-window-height))))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6050 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6051 ((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
6052 (keep-current
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6053 ;; 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
6054 (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
6055 (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
6056
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6057 (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
6058 ;; 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
6059 ;; also with HELP-STRING.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6060 ;; 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
6061 (let ((char ?\?))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6062 (save-window-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6063 (catch 'exit
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6064 (message (concat prompt " (?=Help)"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6065 (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
6066 (= ?\? (setq char (read-char-exclusive))))
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
6067 (reftex-kill-buffer "*RefTeX Select*")
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
6068 (switch-to-buffer-other-window "*RefTeX Select*")
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
6069 (insert help-string)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
6070 (goto-char 1)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
6071 (unless (and (pos-visible-in-window-p 1)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
6072 (pos-visible-in-window-p (point-max)))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
6073 (enlarge-window (1+ (- (count-lines 1 (point-max))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
6074 (reftex-window-height)))))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6075 (setq truncate-lines t))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6076 (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
6077 (message prompt)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6078 (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
6079 (while t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6080 (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
6081 ((equal char ?\?))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6082 ((and scroll (equal char ?\ ))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6083 (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
6084 (message prompt))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6085 ((and scroll (equal char ?\C-? ))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6086 (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
6087 (message prompt))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6088 (t (throw 'exit char)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6089 (setq char (read-char-exclusive)))))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6090
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6091 (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
6092 ;; 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
6093 (let ((start -2))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6094 (setq string (regexp-quote string))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6095 (while (setq start (string-match "[\n\r]" string (+ 3 start)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6096 (setq string (replace-match "[\n\r]" nil t string)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6097 string))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6098
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6099 (defun reftex-get-buffer-visiting (file)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6100 ;; return a buffer visiting FILE
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6101 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6102 ((boundp 'find-file-compare-truenames) ; XEmacs
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6103 (let ((find-file-compare-truenames t))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6104 (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
6105 ((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
6106 (find-buffer-visiting file))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6107 (t (error "This should not happen (reftex-get-buffer-visiting)"))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6108
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6109 ;; 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
6110 (defvar message-stack)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6111 (if (and (featurep 'xemacs)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6112 (not (fboundp 'current-message)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6113 (defun current-message (&optional frame)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6114 (cdr (car message-stack))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6115
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6116 (defun reftex-visited-files (list)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6117 ;; 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
6118 (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
6119 list)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6120
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6121 (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
6122 ;; 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
6123 ;; 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
6124 ;; 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
6125 ;; 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
6126 ;; and mark the buffer to be killed after use.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6127
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6128 (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
6129
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6130 (cond (buf
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6131 ;; 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
6132 buf)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6133
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6134 ((file-readable-p file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6135 ;; 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
6136
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6137 (if (or (not mark-to-kill)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6138 (eq t reftex-initialize-temporary-buffers))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6139
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6140 ;; Visit the file with full magic
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6141 (setq buf (find-file-noselect file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6142
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6143 ;; 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
6144 ;; with limited Magic
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6145
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6146 ;; The magic goes away
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6147 (let ((format-alist nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6148 (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
6149 (default-major-mode 'fundamental-mode)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
6150 (enable-local-variables nil)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6151 (after-insert-file-functions nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6152 (setq buf (find-file-noselect file)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6153
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6154 ;; Is there a hook to run?
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6155 (when (listp reftex-initialize-temporary-buffers)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6156 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6157 (set-buffer buf)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6158 (run-hooks 'reftex-initialize-temporary-buffers))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6159
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6160 ;; 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
6161 (and mark-to-kill
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6162 (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
6163
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6164 ;; Return the new buffer
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6165 buf)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6166
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6167 ;; 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
6168 (t nil))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6169
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6170 (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
6171 ;; 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
6172 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6173 (buffer
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6174 (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
6175 (kill-buffer buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6176 (setq reftex-buffers-to-kill
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6177 (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
6178 (t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6179 (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
6180 (when (bufferp buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6181 (and (buffer-modified-p buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6182 (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
6183 (buffer-file-name buffer)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6184 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6185 (set-buffer buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6186 (save-buffer)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6187 (kill-buffer buffer))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6188 (pop reftex-buffers-to-kill)))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6189
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6190 (defun reftex-splice-symbols-into-list (list alist)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6191 ;; 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
6192 ;; Return new list.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6193 (let (rtn tmp)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6194 (while list
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6195 (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
6196 (symbolp (car list)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6197 (setq tmp (car list))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6198 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6199 ((assoc tmp alist)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
6200 (setq list (append (nth 2 (assoc tmp alist)) (cdr list))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6201 (t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6202 (error "Cannot treat symbol %s in reftex-label-alist"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6203 (symbol-name tmp)))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6204 (push (pop list) rtn))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6205 (nreverse rtn)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6206
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6207 (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
6208 ;; 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
6209 ;; Elements of KEEP-LIST are not removed even if duplicate.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6210 (let (new elm)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6211 (while alist
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6212 (setq elm (pop alist))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6213 (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
6214 (not (assoc (car elm) new)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6215 (push elm new)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6216 (nreverse new)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6217
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6218 ;;; =========================================================================
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6219 ;;;
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6220 ;;; Fontification and Highlighting
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6221
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6222 (defun reftex-use-fonts ()
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
6223 ;; Return t if we can and want to use fonts.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6224 (and window-system
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6225 reftex-use-fonts
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6226 (featurep 'font-lock)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6227
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6228 (defun reftex-refontify ()
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6229 ;; 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
6230 (and (reftex-use-fonts)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6231 (or (eq t reftex-refontify-context)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6232 (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
6233 ;; 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
6234 (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
6235
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6236 (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
6237 ;; 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
6238 ;; 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
6239 (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
6240 parent-buffer 'reftex-ref)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6241 (let* ((oldname (buffer-name))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6242 (newname (concat "Fontify-me-" oldname)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6243 (unwind-protect
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6244 (progn
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6245 ;; 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
6246 (rename-buffer newname t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6247 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6248 ((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
6249 ;; 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
6250 (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
6251 '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
6252 (let ((major-mode 'latex-mode))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6253 (font-lock-mode 1)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6254 ((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
6255 ;; 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
6256 ;; 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
6257 (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
6258 (let ((major-mode 'latex-mode)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6259 (font-lock-defaults-computed nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6260 (font-lock-set-defaults-1)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6261 (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
6262 (t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6263 ;; Oops?
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6264 (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
6265 (rename-buffer oldname))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6266
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6267 (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
6268 ;; 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
6269 (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
6270 'font-lock-default-fontify-region
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6271 'font-lock-fontify-region))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6272 beg1 end1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6273 (goto-char beg)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6274 (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
6275 (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
6276 (funcall func beg1 end1 nil)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6277 (goto-char end1))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6278
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6279 (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
6280
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6281 (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
6282 ;; 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
6283 ;; 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
6284 ;; 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
6285 ;; 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
6286 ;; 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
6287 ;; to font-lock-constant-face.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6288 (let (face)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6289 (catch 'exit
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6290 (while (setq face (pop faces))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6291 (if (featurep 'xemacs)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6292 (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
6293 (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
6294
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6295 ;; 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
6296 (if (featurep 'xemacs) (require 'overlay))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6297
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6298 ;; 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
6299 (defvar reftex-highlight-overlays [nil nil])
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6300
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6301 ;; Initialize the overlays
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6302 (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
6303 (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
6304 'face 'highlight)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6305 (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
6306 (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
6307 'face reftex-cursor-selected-face)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6308
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6309 ;; Two functions for activating and deactivation highlight overlays
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6310 (defun reftex-highlight (index begin end &optional buffer)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6311 "Highlight a region with overlay INDEX."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6312 (move-overlay (aref reftex-highlight-overlays index)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6313 begin end (or buffer (current-buffer))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6314 (defun reftex-unhighlight (index)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6315 "Detach overlay INDEX."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6316 (delete-overlay (aref reftex-highlight-overlays index)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6317
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6318 (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
6319 ;; Function used in pre-command-hook to remove highlights.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6320 (remove-hook 'pre-command-hook 'reftex-highlight-shall-die)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6321 (reftex-unhighlight 0))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6322
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6323 ;;; =========================================================================
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6324 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6325 ;;; Functions to compile the tables, reset the mode etc.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6326
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6327 ;; 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
6328 ;; 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
6329 (defconst reftex-cache-variables
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6330 '(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
6331 reftex-env-or-mac-alist reftex-everything-regexp
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
6332 reftex-macros-with-labels
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6333 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
6334 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
6335 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
6336 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
6337 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
6338 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
6339 reftex-words-to-typekey-alist))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6340
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6341 (defun reftex-ensure-compiled-variables ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6342 ;; 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
6343 (let* ((mem reftex-memory)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6344 (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
6345 (cmem (car cache))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6346 (alist reftex-label-alist)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6347 (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
6348 (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
6349 (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
6350 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6351 (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
6352 ((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
6353 (eq levels (nth 1 mem))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6354 (eq style (nth 2 mem))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6355 (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
6356 ((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
6357 (eq levels (nth 1 cmem))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6358 (eq style (nth 2 cmem))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6359 (eq default (nth 2 cmem)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6360 ;; restore the cache
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6361 (message "Restoring cache")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6362 (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
6363 (t (reftex-compile-variables)))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6364
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6365 (defun reftex-reset-mode ()
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6366 "Reset RefTeX Mode.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6367 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
6368 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
6369 on next use."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6370 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6371
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6372 ;; 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
6373 (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
6374 (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
6375 (put 'reftex-bib-path prop nil))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6376
18219
aaeaae005e98 Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents: 18123
diff changeset
6377 ;; 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
6378 ;; 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
6379 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6380 (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
6381 "*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
6382 buf)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6383 (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
6384 (if (get-buffer buf)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6385 (kill-buffer buf))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6386 (reftex-erase-all-selection-buffers))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6387
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6388 ;; 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
6389 (reftex-reset-scanning-information)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
6390
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6391 ;; Remove any parse info file
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6392 (reftex-access-parse-file 'kill)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6393
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6394 ;; 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
6395 (and reftex-plug-into-AUCTeX
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6396 (reftex-plug-into-AUCTeX))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6397
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6398 (reftex-compile-variables))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6399
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6400 (defun reftex-reset-scanning-information ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6401 "Reset the symbols containing information from buffer scanning.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6402 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
6403 (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
6404 (reftex-erase-buffer "*toc*"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6405 (let ((symlist reftex-multifile-symbols)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6406 symbol)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6407 (while symlist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6408 (setq symbol (car symlist)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6409 symlist (cdr symlist))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6410 (if (and (symbolp (symbol-value symbol))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6411 (not (null (symbol-value symbol))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6412 (set (symbol-value symbol) nil)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6413
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6414 (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
6415 ;; 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
6416 (mapcar
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6417 (lambda (type)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6418 (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
6419 reftex-typekey-list))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6420
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6421 (defun reftex-compile-variables ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6422 ;; 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
6423
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6424 (message "Compiling label environment definitions...")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6425
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6426 ;; Update AUCTeX style information
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6427 (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
6428 (condition-case nil (TeX-update-style) (error nil)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6429
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6430 ;; 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
6431 (setq reftex-tables-dirty nil)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6432 (setq reftex-memory
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6433 (list reftex-label-alist
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6434 (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
6435 (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
6436 reftex-default-label-alist-entries))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6437
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6438 ;; 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
6439 (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
6440 (reftex-splice-symbols-into-list
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6441 (append reftex-label-alist
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6442 (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
6443 reftex-default-label-alist-entries)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6444 reftex-label-alist-builtin)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6445 '(nil)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6446 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
6447 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
6448 nargs nlabel opt-args cell sum i)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6449
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6450 (setq reftex-words-to-typekey-alist nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6451 reftex-typekey-list nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6452 reftex-typekey-to-format-alist nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6453 reftex-typekey-to-prefix-alist nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6454 reftex-env-or-mac-alist nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6455 reftex-label-env-list nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6456 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
6457 (while all
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6458 (catch 'next-entry
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6459 (setq entry (car all)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6460 env-or-mac (car entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6461 entry (cdr entry)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6462 all (cdr all))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6463 (if (null env-or-mac)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6464 (setq env-or-mac ""))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6465 (if (stringp (car entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6466 ;; 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
6467 ;; 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
6468 (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
6469 (cons (concat (car entry) ":")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6470 (cdr entry)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6471 (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
6472 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
6473 prefix (nth 1 entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6474 fmt (nth 2 entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6475 context (nth 3 entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6476 wordlist (nth 4 entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6477 (if (stringp wordlist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6478 ;; 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
6479 (setq wordlist (nthcdr 4 entry)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6480
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6481 (if (and (stringp fmt)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6482 (string-match "@" fmt))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6483 ;; 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
6484 (setq fmt (split-string fmt "@+"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6485 (setq fmt (list "\\label{%s}" fmt)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6486 (setq labelfmt (car fmt)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6487 reffmt (nth 1 fmt))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6488 ;; Note a new typekey
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6489 (if typekey
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6490 (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
6491 (if (and typekey prefix
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6492 (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
6493 (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
6494 (cons typekey prefix)))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6495 ;; 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
6496 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6497 ((string-match "\\`\\\\" env-or-mac)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6498 ;; It's a macro
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6499 (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
6500 (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
6501 nargs (second result)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6502 nlabel (third result)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6503 opt-args (fourth result))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6504 (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
6505 (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
6506 (t
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6507 ;; It's an environment
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6508 (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
6509 (cond ((string= env-or-mac "any"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6510 ((string= env-or-mac ""))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6511 ((string= env-or-mac "section"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6512 (t
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6513 (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
6514 ;; Translate some special context cases
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6515 (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
6516 (setq context
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6517 (format
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6518 (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
6519 (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
6520 ;; 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
6521 (and reffmt
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6522 (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
6523 (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
6524 ;; 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
6525 (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
6526 (not (string= env-or-mac ""))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6527 (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
6528 (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
6529 nargs nlabel opt-args)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6530 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
6531 ;; 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
6532 (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
6533 (setq wordlist (cdr wordlist))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6534 (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
6535 ;; 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
6536 (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
6537 (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
6538 (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
6539 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6540 ((string= "" env-or-mac) nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6541 ((setq cell (assoc typekey qh-list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6542 (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
6543 (typekey
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6544 (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
6545
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6546 (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
6547 (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
6548
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6549 ;; 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
6550 (setq qh-list
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6551 (sort qh-list (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6552 (lambda (x1 x2) (string< (car x1) (car x2))))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6553 (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
6554 (concat "Label type: ["
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6555 (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
6556 qh-list "")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6557 "]"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6558 ;; In the help string, we need to wrap lines...
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6559 (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
6560 (concat
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6561 "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
6562 (mapconcat
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6563 (lambda(x)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6564 (setq sum 0)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6565 (format " [%s] %s"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6566 (car x)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6567 (mapconcat (lambda(env)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6568 (setq sum (+ sum (length env)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6569 (if (< sum 60)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6570 env
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6571 (setq sum 0)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6572 (concat "\n " env)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6573 (cdr x) " ")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6574 qh-list "\n")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6575
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6576 ;; 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
6577 ;; 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
6578 ;; 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
6579 (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
6580 (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6581 (lambda (x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6582 (setq word (car x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6583 typekey (cdr x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6584 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
6585 (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
6586 (setq i 0)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6587 (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
6588 (< i (length fmt))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6589 (not (member (aref fmt i) '(?%))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6590 (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
6591 (substring fmt 0 (1+ i)))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6592 (incf i))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6593 (cons (concat word "\\)\\=") typekey))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
6594 (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
6595
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6596 ;; 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
6597 (setq reftex-section-levels-all
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6598 (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
6599 reftex-section-levels))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6600
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6601 ;; Calculate the regular expressions
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6602 (let* ((wbol "\\(\\`\\|[\n\r]\\)[ \t]*")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6603 (label-re "\\\\label{\\([^}]*\\)}")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6604 (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
6605 (section-re
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6606 (concat wbol "\\\\\\("
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6607 (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
6608 "\\)\\*?\\(\\[[^]]*\\]\\)?{"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6609 (appendix-re (concat wbol "\\(\\\\appendix\\)"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6610 (macro-re
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6611 (if macros-with-labels
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6612 (concat "\\("
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6613 (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
6614 "\\)[[{]")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6615 ""))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6616 (find-label-re-format
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6617 (concat "\\("
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6618 (mapconcat 'regexp-quote (append '("\\label")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6619 macros-with-labels) "\\|")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6620 "\\)\\([[{][^]}]*[]}]\\)*[[{]\\(%s\\)[]}]")))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6621 (setq reftex-section-regexp section-re
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6622 reftex-section-or-include-regexp
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6623 (concat section-re "\\|" include-re)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6624 reftex-everything-regexp
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6625 (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
6626 "\\|" appendix-re
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6627 (if macros-with-labels "\\|" "") macro-re)
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
6628 reftex-macros-with-labels macros-with-labels
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
6629 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
6630 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
6631 "\\([]} \t\n\r]\\)\\([[{]\\)\\(%s\\)[]}]")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6632 (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
6633 (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
6634 (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
6635
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6636 ;;; =========================================================================
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6637 ;;;
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6638 ;;; Operations on entire Multifile documents
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6639
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6640 (defun reftex-create-tags-file ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6641 "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
6642 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
6643 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6644 (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
6645 (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
6646 (files (reftex-all-document-files))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6647 (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
6648 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6649 (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
6650 (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
6651 (shell-command cmd)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6652 (visit-tags-table "TAGS"))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6653
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6654 ;; History of grep commands.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6655 (defvar reftex-grep-history nil)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6656 (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
6657 "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
6658
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6659 (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
6660 "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
6661 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
6662 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
6663
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6664 (interactive
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6665 (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
6666 reftex-grep-command nil nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6667 'reftex-grep-history)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6668 (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
6669 (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
6670 (cmd (format
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6671 "%s %s" grep-cmd
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6672 (mapconcat 'identity files " "))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6673 (grep cmd)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6674
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6675 (defun reftex-search-document (&optional regexp)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
6676 "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
6677 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
6678 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
6679 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
6680 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6681 (let ((default (reftex-this-word)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6682 (unless regexp
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6683 (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
6684 default))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6685 (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
6686
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6687 (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
6688 (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
6689
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6690 (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
6691 "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
6692 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
6693 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
6694 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
6695 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
6696 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6697 (let ((default (reftex-this-word)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6698 (unless from
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6699 (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
6700 default)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6701 (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
6702 (unless to
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6703 (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
6704 (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
6705 (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
6706 (list 'reftex-all-document-files))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6707
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6708 (defun reftex-find-duplicate-labels ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6709 "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
6710
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6711 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6712
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6713 ;; 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
6714 (reftex-access-scan-info t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6715
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6716 (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
6717 (cnt 0)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6718 (dlist
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6719 (mapcar
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6720 (function
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6721 (lambda (x)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6722 (let (x1)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6723 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6724 ((memq (car x)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6725 '(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
6726 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
6727 is-multi))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6728 nil)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6729 (t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6730 (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
6731 (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
6732 (if (< 1 (length x1))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6733 (append (list (car x))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6734 (mapcar (function
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6735 (lambda(x)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6736 (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
6737 x1))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6738 (list nil)))))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6739 (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
6740
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6741 (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
6742 (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
6743 (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
6744 (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
6745 (erase-buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6746 (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
6747 (insert
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6748 " 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
6749 " 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
6750 (insert " LABEL FILE\n")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6751 (insert " -------------------------------------------------------------\n")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6752 (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
6753 (local-set-key [?q] (function
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6754 (lambda () "Kill this buffer." (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6755 (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
6756 (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
6757 (while dlist
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6758 (when (and (car (car dlist))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6759 (cdr (car dlist)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6760 (incf cnt)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6761 (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
6762 (pop dlist))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6763 (goto-char (point-min))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6764 (when (= cnt 0)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6765 (kill-buffer (current-buffer))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6766 (delete-window)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6767 (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
6768
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6769 (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
6770 "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
6771 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
6772 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
6773 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
6774 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
6775 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6776 (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
6777 (unless from
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6778 (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
6779 default))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6780 (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
6781 (unless to
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6782 (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
6783 from))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6784 (reftex-query-replace-document
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6785 (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
6786 (format "\\\\\\1{%s}" to))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6787
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6788 (defun reftex-renumber-simple-labels ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6789 "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
6790 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
6791 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
6792 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
6793 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
6794 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
6795 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
6796 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
6797 one with the `xr' package."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6798 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6799 ;; Resan the entire document
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6800 (reftex-access-scan-info 1)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6801 ;; Get some insurance
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6802 (if (and (reftex-is-multi)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6803 (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
6804 (error "Abort"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6805 ;; Make the translation list
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6806 (let* ((re-core (concat "\\("
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6807 (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
6808 "\\)"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6809 (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
6810 (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
6811 (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
6812 (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
6813 reftex-typekey-to-prefix-alist))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6814 (files (reftex-all-document-files))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6815 (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
6816 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
6817
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6818 (while (setq entry (pop list))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6819 (when (and (stringp (car entry))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6820 (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
6821 (setq label (car entry)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6822 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
6823 label-numbers-alist))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6824 (if (assoc label translate-alist)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6825 (error "Duplicate label %s" label))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6826 (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
6827 (incf (cdr nr-cell))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6828 (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
6829 (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
6830
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6831 (unless changed-sequence
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6832 (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
6833
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6834 ;; 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
6835 (reftex-save-all-document-buffers)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6836
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6837 ;; 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
6838 (setq n (reftex-translate
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6839 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
6840
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6841 ;; Now the real thing.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6842 (if (yes-or-no-p
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6843 (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
6844 (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
6845 (progn
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6846 (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
6847 (reftex-translate
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6848 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
6849 (setq quit-flag nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6850 (if (and (reftex-is-multi)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6851 (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
6852 (reftex-save-all-document-buffers))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6853 ;; Rescan again...
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6854 (reftex-access-scan-info 1)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6855 (message "Done replacing simple labels."))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6856 (message "No replacements done"))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6857
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6858 (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
6859 ;; 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
6860 ;; its association in TRANSLATE-ALSIT.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6861 ;; 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
6862 ;; to ignore the problematic string.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6863 ;; 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
6864 ;; Return the number of replacements.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6865 (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
6866 (while (setq file (pop files))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6867 (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
6868 (unless buf
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6869 (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
6870 (set-buffer buf)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6871 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6872 (save-restriction
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6873 (widen)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6874 (goto-char (point-min))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6875 (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
6876 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6877 (backward-char)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6878 (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
6879 cell (assoc label translate-alist)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6880 match-data (match-data)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6881 macro (reftex-what-macro 1)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6882 pos (cdr macro))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6883 (goto-char (or pos (point)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6884 (when (and macro
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6885 (or (looking-at "\\\\ref")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6886 (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
6887 (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
6888 (looking-at (format
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6889 reftex-find-label-regexp-format
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6890 (regexp-quote label)))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6891 ;; OK, we should replace it.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6892 (set-match-data match-data)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6893 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6894 ((and test (not cell))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6895 ;; We've got a problem
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6896 (unwind-protect
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6897 (progn
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6898 (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
6899 (ding)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6900 (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
6901 (error "Abort")))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6902 (reftex-unhighlight 1)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6903 ((and test cell)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6904 (incf n))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6905 ((and (not test) cell)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6906 ;; Replace
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6907 (goto-char (match-beginning 1))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6908 (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
6909 (insert (cdr cell)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6910 (t nil))))))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6911 n))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6912
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6913 (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
6914 "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
6915 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
6916 labels."
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6917 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6918 (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
6919 file buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6920 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6921 (while (setq file (pop files))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6922 (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
6923 (when buffer
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6924 (set-buffer buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6925 (save-buffer))))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6926
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 ;;;
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6929 ;;; AUCTeX Interface
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6930
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6931 (defun reftex-plug-flag (which)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6932 ;; 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
6933 (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
6934 (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
6935 (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
6936
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6937 (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
6938 "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
6939 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
6940 (let (label)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6941 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6942 ((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
6943 ;; 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
6944 (unwind-protect
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6945 (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
6946 (delete-backward-char 1)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6947 ((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
6948 ;; Reference a label with RefTeX
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6949 (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
6950 (t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6951 ;; AUCTeX's default mechanism
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6952 (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
6953 (LaTeX-label-list)))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6954 (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
6955 (LaTeX-add-labels label))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6956 (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
6957
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6958 (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
6959 "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
6960 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
6961 (let (items)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6962 (cond
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6963 ((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
6964 (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
6965 (t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6966 (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
6967 (if prompt prompt "Add key")
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6968 ": (default none) "))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6969 (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
6970 (apply 'LaTeX-add-bibitems items)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6971 (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
6972
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6973 (defun reftex-plug-into-AUCTeX ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6974 ;; 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
6975 ;; 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
6976 ;; `reftex-plug-into-AUCTeX'.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6977
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6978 (if (reftex-plug-flag 0)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6979 (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
6980 (setq LaTeX-label-function nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6981
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6982 (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
6983 (fboundp 'TeX-arg-label))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6984 (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
6985
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6986 (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
6987 (fboundp 'TeX-arg-cite))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6988 (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
6989
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6990 (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
6991 "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
6992 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6993 (unless (and (featurep 'tex-site) (featurep 'latex))
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
6994 (error "AUCTeX's LaTeX mode does not seem to be loaded"))
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6995 (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
6996 (reftex-plug-into-AUCTeX)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6997 (if reftex-plug-into-AUCTeX
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
6998 (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
6999 (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
7000
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7001 (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
7002 "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
7003 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
7004 for details.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7005 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
7006 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
7007 `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
7008 `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
7009 `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
7010 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
7011 (unless reftex-docstruct-symbol
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7012 (reftex-tie-multifile-symbols))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7013 (when (and reftex-docstruct-symbol
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7014 (symbolp reftex-docstruct-symbol))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7015 (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
7016 entry changed)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7017 (while entry-list
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7018 (setq entry (pop entry-list))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7019 (unless (member entry list)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7020 (setq reftex-tables-dirty t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7021 changed t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7022 (push entry list)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7023 (when changed
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7024 (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
7025 (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
7026
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7027 (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
7028 "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
7029 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
7030 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
7031 `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
7032 (unless reftex-docstruct-symbol
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7033 (reftex-tie-multifile-symbols))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7034 (when (and reftex-docstruct-symbol
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7035 (symbolp reftex-docstruct-symbol))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7036 (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
7037 entry changed)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7038 (while entry-list
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7039 (setq entry (pop entry-list))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7040 (unless (member entry list)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7041 (setq reftex-tables-dirty t
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7042 changed t)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7043 (push entry list)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7044 (when changed
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7045 (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
7046
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7047 (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
7048 "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
7049 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
7050 `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
7051 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
7052 (unless reftex-docstruct-symbol
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7053 (reftex-tie-multifile-symbols))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7054 (when (and reftex-docstruct-symbol
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7055 (symbolp reftex-docstruct-symbol))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7056 (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
7057
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7058 (defun reftex-notice-new-section ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7059 "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
7060 ;; 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
7061 ;; 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
7062 ;; 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
7063 ;; section label is created.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7064
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7065 (condition-case nil
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7066 (catch 'exit
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7067 (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
7068 (reftex-access-scan-info)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7069 (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
7070 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
7071 section-number context)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7072
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7073 (save-excursion
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7074 (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
7075
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7076 ;; Find where we are
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7077 (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
7078 (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
7079 (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
7080 '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
7081 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
7082 '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
7083
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7084 ;; Initialize section numbers
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7085 (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
7086 (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
7087 (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
7088
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7089 ;; Match the section command
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7090 (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
7091 (match-end 3))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7092 (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
7093 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
7094 level (nth 5 toc-entry)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7095 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
7096 (symbol-value reftex-docstruct-symbol)))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7097 (if tail
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7098 ;; Insert the section info
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7099 (push toc-entry (cdr tail))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7100 (throw 'exit nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7101
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7102 ;; 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
7103 (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
7104
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7105 ;; Update the remaining toc items
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7106 (setq tail (cdr tail))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7107 (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
7108 (setq toc-entry (car tail))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7109 (>= (nth 5 toc-entry) level))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7110 (setq section-number
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7111 (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
7112 context (nth 2 toc-entry))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7113 (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
7114 context)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7115 (when (and (not appendix)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7116 (>= (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
7117 ;; 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
7118 (throw 'exit nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7119
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7120 ;; Change the section number.
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7121 (setf (nth 2 toc-entry)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7122 (concat (match-string 1 context)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7123 section-number
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7124 (match-string 3 context))))))))))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7125 (error nil))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7126 )
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7127
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7128 ;;; =========================================================================
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7129 ;;;
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7130 ;;; Keybindings
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7131
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7132 ;; 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
7133 (loop for x in
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7134 '(("\C-c=" . reftex-toc)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7135 ("\C-c(" . reftex-label)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7136 ("\C-c)" . reftex-reference)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7137 ("\C-c[" . reftex-citation)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7138 ("\C-c&" . reftex-view-crossref))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7139 do (define-key reftex-mode-map (car x) (cdr x)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7140
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7141 (eval-after-load
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7142 "bibtex"
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7143 '(define-key bibtex-mode-map "\C-c&" 'reftex-view-crossref-from-bibtex))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7144
21130
60e882bbb28b Added keybinding for `reftex-mouse-view-crossref' to S-mouse-2.
Carsten Dominik <dominik@science.uva.nl>
parents: 21124
diff changeset
7145 ;; Bind `reftex-mouse-view-crossref' only when the key is still free
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7146 (let ((key (if (featurep 'xemacs) [(shift button2)] [(shift mouse-2)])))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7147 (unless (key-binding key)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7148 (define-key reftex-mode-map key 'reftex-mouse-view-crossref)))
21130
60e882bbb28b Added keybinding for `reftex-mouse-view-crossref' to S-mouse-2.
Carsten Dominik <dominik@science.uva.nl>
parents: 21124
diff changeset
7149
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7150 ;; 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
7151 (when reftex-extra-bindings
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7152 (loop for x in
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7153 '(("\C-ct" . reftex-toc)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7154 ("\C-cl" . reftex-label)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7155 ("\C-cr" . reftex-reference)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7156 ("\C-cc" . reftex-citation)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7157 ("\C-cv" . reftex-view-crossref)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7158 ("\C-cg" . reftex-grep-document)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7159 ("\C-cs" . reftex-search-document))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7160 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
7161
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7162 ;; 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
7163 (let ((map (make-sparse-keymap)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
7164 (substitute-key-definition
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
7165 '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
7166 (substitute-key-definition
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
7167 '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
7168 (substitute-key-definition
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
7169 '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
7170 (substitute-key-definition
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
7171 '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
7172
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7173 (loop for x in
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7174 '((" " . reftex-select-callback)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7175 ("n" . reftex-select-next)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7176 ([(down)] . reftex-select-next)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7177 ("p" . reftex-select-previous)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7178 ([(up)] . reftex-select-previous)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7179 ("f" . reftex-select-toggle-follow)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7180 ("\C-m" . reftex-select-accept)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7181 ([(return)] . reftex-select-accept)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7182 ("q" . reftex-select-quit)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7183 ("." . reftex-select-show-insertion-point)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7184 ("?" . reftex-select-help))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7185 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
7186
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7187 ;; The mouse-2 binding
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7188 (define-key map (if (featurep 'xemacs) [(button2)] [(mouse-2)])
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7189 'reftex-select-mouse-accept)
22991
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 ;; Digit arguments
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
7192 (loop for key across "0123456789" do
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
7193 (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
7194 (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
7195
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7196 ;; Make two maps
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
7197 (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
7198 (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
7199
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7200 ;; 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
7201 (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
7202 (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
7203 (list 'lambda '()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7204 "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
7205 '(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
7206
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7207 (loop for x in
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7208 '(("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
7209 ("v" . reftex-select-toggle-varioref)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7210 ([(tab)] . reftex-select-read-label)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7211 ("\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
7212 ("\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
7213 ("\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
7214 do
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7215 (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
7216
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7217 ;; 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
7218 (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
7219 (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
7220 (list 'lambda '()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7221 "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
7222 '(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
7223
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7224 (loop for x in
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7225 '(("\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
7226 ([(tab)] . reftex-select-read-cite))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7227 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
7228
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
7229 ;; Table of Contents map
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7230 (define-key reftex-toc-map (if (featurep 'xemacs) [(button2)] [(mouse-2)])
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7231 'reftex-toc-mouse-goto-line-and-hide)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7232
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7233 (substitute-key-definition
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7234 '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
7235 (substitute-key-definition
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7236 '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
7237
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7238 (loop for x in
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7239 '(("n" . reftex-toc-next)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7240 ("p" . reftex-toc-previous)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7241 ("?" . reftex-toc-show-help)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7242 (" " . reftex-toc-view-line)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7243 ("\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
7244 ("\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
7245 ("r" . reftex-toc-rescan)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7246 ("R" . reftex-toc-Rescan)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7247 ("g" . revert-buffer)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7248 ("q" . reftex-toc-quit)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7249 ("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
7250 ("f" . reftex-toc-toggle-follow)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7251 ("i" . reftex-toc-toggle-file-boundary)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7252 ("l" . reftex-toc-toggle-labels)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7253 ("c" . reftex-toc-toggle-context)
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7254 ("%" . reftex-toc-toggle-commented)
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7255 ("x" . reftex-toc-external)
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7256 ("." . 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
7257 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
7258
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7259 (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
7260 (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
7261 (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
7262
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7263 ;;; =========================================================================
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7264 ;;;
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7265 ;;; Menu
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7266
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7267 ;; 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
7268
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7269 (require 'easymenu)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7270
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7271 (easy-menu-define reftex-mode-menu reftex-mode-map
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7272 "Menu used in RefTeX mode"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
7273 `("Ref"
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
7274 ["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
7275 "---"
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
7276 ["\\label" reftex-label t]
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
7277 ["\\ref" reftex-reference t]
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
7278 ["\\cite" reftex-citation t]
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
7279 ["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
7280 "---"
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
7281 ("Parse Document"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
7282 ["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
7283 ["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
7284 ["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
7285 (> (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
7286 ["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
7287 "---"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
7288 ["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
7289 ("Global Actions"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
7290 ["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
7291 ["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
7292 ["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
7293 "---"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
7294 ["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
7295 "---"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
7296 ["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
7297 ["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
7298 ["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
7299 "---"
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7300 ["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
7301 "---"
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7302 ("Options"
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7303 "PARSER"
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7304 ["Partial Scans"
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7305 (setq reftex-enable-partial-scans (not reftex-enable-partial-scans))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7306 :style toggle :selected reftex-enable-partial-scans]
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7307 ["Auto-Save Parse Info"
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7308 (setq reftex-save-parse-info (not reftex-save-parse-info))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7309 :style toggle :selected reftex-save-parse-info]
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7310 "---"
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7311 "CROSSREF INFO"
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7312 ["Automatic Info" reftex-toggle-auto-view-crossref
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7313 :style toggle :selected reftex-auto-view-crossref-timer]
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7314 ["...in Echo Area" (setq reftex-auto-view-crossref t)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7315 :style radio :selected (eq reftex-auto-view-crossref t)]
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7316 ["...in Other Window" (setq reftex-auto-view-crossref 'window)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7317 :style radio :selected (eq reftex-auto-view-crossref 'window)]
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7318 "---"
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7319 "MISC"
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7320 ["AUC TeX Interface" reftex-toggle-plug-into-AUCTeX
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7321 :style toggle :selected reftex-plug-into-AUCTeX])
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7322 ("Reference Style"
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7323 ["Standard" (setq reftex-vref-is-default nil)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7324 :style radio :selected (not reftex-vref-is-default)]
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7325 ["Varioref" (setq reftex-vref-is-default t)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7326 :style radio :selected reftex-vref-is-default])
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7327 ("Citation Style"
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7328 ,@(mapcar
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7329 (function
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7330 (lambda (x)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7331 (vector
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7332 (capitalize (symbol-name (car x)))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7333 (list 'reftex-set-cite-format (list 'quote (car x)))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7334 :style 'radio :selected
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7335 (list 'eq (list 'reftex-get-cite-format) (list 'quote (car x))))))
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7336 reftex-cite-format-builtin)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7337 "---"
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7338 "Sort Database Matches"
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7339 ["Not" (setq reftex-sort-bibtex-matches nil)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7340 :style radio :selected (eq reftex-sort-bibtex-matches nil)]
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7341 ["by Author" (setq reftex-sort-bibtex-matches 'author)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7342 :style radio :selected (eq reftex-sort-bibtex-matches 'author)]
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7343 ["by Year" (setq reftex-sort-bibtex-matches 'year)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7344 :style radio :selected (eq reftex-sort-bibtex-matches 'year)]
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7345 ["by Year, reversed" (setq reftex-sort-bibtex-matches 'reverse-year)
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7346 :style radio :selected (eq reftex-sort-bibtex-matches 'reverse-year)])
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7347 "---"
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
7348 ("Customize"
23707
b0fe513da546 (reftex-finding-files): Group documentation fixed.
Carsten Dominik <dominik@science.uva.nl>
parents: 23344
diff changeset
7349 ["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
7350 "---"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
7351 ["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
7352 (fboundp 'customize-menu-create)])
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
7353 ("Documentation"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
7354 ["Info" reftex-info t]
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
7355 ["Commentary" reftex-show-commentary t])))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7356
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7357 (defun reftex-customize ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7358 "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
7359 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7360 (customize-browse 'reftex))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7361
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7362 (defun reftex-create-customize-menu ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7363 "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
7364 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7365 (if (fboundp 'customize-menu-create)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7366 (progn
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7367 (easy-menu-change
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7368 '("Ref") "Customize"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7369 `(["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
7370 "---"
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7371 ,(customize-menu-create 'reftex)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7372 ["Set" Custom-set t]
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7373 ["Save" Custom-save t]
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7374 ["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
7375 ["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
7376 ["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
7377 (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
7378 (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
7379
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7380 (defun reftex-show-commentary ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7381 "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
7382 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7383 (require 'finder)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7384 (finder-commentary "reftex.el"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7385
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7386 (defun reftex-info ()
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7387 "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
7388 (interactive)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7389 (require 'info)
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7390 (Info-goto-node "(reftex)"))
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7391
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7392 ;;; 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
7393
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7394 (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
7395 (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
7396
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7397 ;;; Run Hook ------------------------------------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7398
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7399 (run-hooks 'reftex-load-hook)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7400
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7401 ;;; That's it! ----------------------------------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7402
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
7403 (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
7404 (provide 'reftex)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
7405
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7406 ;;;============================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7407
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
7408 ;;; reftex.el ends here
22991
313091cd2751 (reftex-reparse-document): Renamed from `reftex-parse-document'.
Carsten Dominik <dominik@science.uva.nl>
parents: 22388
diff changeset
7409
23995
a56b80c4166a (reftex-section-levels): Allow negative levels.
Carsten Dominik <dominik@science.uva.nl>
parents: 23707
diff changeset
7410