annotate lisp/textmodes/reftex.el @ 22643:4f99ccb85f3a

(Info-find-node): Use byte-to-position.
author Richard M. Stallman <rms@gnu.org>
date Mon, 29 Jun 1998 18:34:24 +0000
parents 2d0bece94ee7
children 313091cd2751
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 ;;
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
28 ;; RefTeX is a minor mode with distinct support for \ref, \label and
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
29 ;; \cite commands in (multi-file) LaTeX documents.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; Labels are created semi-automatically. Definition context of labels is
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;; provided when creating a reference. Citations are simplified with
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
32 ;; efficient database lookup. A table of contents buffer provides easy
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
33 ;; access to any part of a document.
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 ;;
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; To turn RefTeX Minor Mode on and off in a particular buffer, use
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;; `M-x reftex-mode'.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;; To turn on RefTeX Minor Mode for all LaTeX files, add one of the
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;; following lines to your .emacs file:
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 ;; (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 ;; (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 ;;
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
45 ;;
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
46 ;; DOCUMENTATION
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
47 ;; -------------
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
48 ;;
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
49 ;; There is an extensive texinfo document describing RefTeX in detail.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
50 ;; When you are getting reftex.el with the Emacs distribution, the
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
51 ;; info files should already be installed. To view this
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
52 ;; documentation, use `M-x reftex-info RET'.
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 ;; The documentation is also available at
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 ;; 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
57 ;;
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
58 ;;---------------------------------------------------------------------------
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
59 ;;
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
60 ;; RefTeX in a Nutshell
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
61 ;; ====================
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
62 ;;
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
63 ;; 1. Labels and References
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
64 ;; RefTeX distinguishes labels for different environments. It always
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
65 ;; knows if a certain label references a figure, table etc.. You can
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
66 ;; configure RefTeX to recognize any additional labeled environments
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
67 ;; you have defined yourself (variable REFTEX-LABEL-ALIST).
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
68 ;; - Creating Labels
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
69 ;; Type `C-c (' (`reftex-label') to insert a label at point.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
70 ;; RefTeX will either
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
71 ;; - derive a label from context (default for section labels)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
72 ;;
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
73 ;; - insert a simple label consisting of a prefix and a number
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
74 ;; (default for equations, enumerate items, and footnotes)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
75 ;; or
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
76 ;;
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
77 ;; - prompt for a label string (figures and tables).
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
78 ;;
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
79 ;; Which labels are created how is configurable (variable
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
80 ;; REFTEX-INSERT-LABEL-FLAGS).
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
81 ;;
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
82 ;; - Referencing Labels
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
83 ;; Referencing labels is a snap and I promise you'll love it.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
84 ;; In order to make a reference, type `C-c )'
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
85 ;; (`reftex-reference'). This shows an outline of the document
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
86 ;; with all labels of a certain type (figure, equation,...) and
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
87 ;; context of the label definition. Selecting one of the labels
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
88 ;; inserts a `\ref' macro into the original buffer. Online help
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
89 ;; during the selection is available with `?'.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
90 ;;
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
91 ;; 2. Citations
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
92 ;; After typing `C-c [' (`reftex-citation'), RefTeX will let you
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
93 ;; specify a regular expression to search in current BibTeX database
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
94 ;; files (as specified in the `\bibliography' command) and pull out a
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
95 ;; formatted list of matches for you to choose from. The list is
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
96 ;; *formatted* and sorted, thus much easier to read than the raw
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
97 ;; database entries. The text inserted into the buffer is by default
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
98 ;; just `\cite{KEY}', but can also contain author names and the year
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
99 ;; in a configurable way (variable REFTEX-CITE-FORMAT).
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
100 ;;
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
101 ;; 3. Viewing Cross References
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
102 ;; With point on or anywhere before a `\ref' or `\cite' macro, press
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
103 ;; `C-c &' (`reftex-view-crossref'). This will display the
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
104 ;; corresponding label definition or BibTeX database entry in another
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
105 ;; window.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
106 ;;
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
107 ;; 4. Table of Contents
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
108 ;; Typing `C-c =' (`reftex-toc') will show a table of contents of the
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
109 ;; document. From that buffer, you can jump quickly to every part of
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
110 ;; your document.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
111 ;;
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
112 ;; 5. Multifile Documents
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
113 ;; Multifile Domuments are fully supported. RefTeX will provide cross
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
114 ;; referencing information from all files which are part of the
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
115 ;; document. You may also use it to reference labels in external
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
116 ;; documents (in cooperation with the LaTeX package `xr').
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
117 ;;
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
118 ;; 6. Document Parsing
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
119 ;; RefTeX needs to parse the document in order to find labels and
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
120 ;; other information. It will do it automatically once, when you
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
121 ;; start working with a document. Re-parsing should not be necessary
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
122 ;; too often since RefTeX updates its lists internally when you make
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
123 ;; a new label with `reftex-label'. To enforce reparsing, call any
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
124 ;; of the commands described above with a raw `C-u' prefix, or press
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
125 ;; the `r' key in the label selection buffer or the table of contents
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
126 ;; buffer.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 ;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 ;;---------------------------------------------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 ;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 ;; AUTHOR
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
131 ;; ======
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 ;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 ;; Carsten Dominik <dominik@strw.LeidenUniv.nl>
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 ;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 ;; with contributions from Stephen Eglen
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 ;; The newest version of RefTeX can be found at
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 ;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 ;; http://www.strw.leidenuniv.nl/~dominik/Tools/
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 ;; ftp://strw.leidenuniv.nl/pub/dominik/
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 ;;
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
142 ;; The version at this site is compatible with Emacs 19 - the version
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
143 ;; distributed with Emacs 20 is not.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
144 ;;
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 ;; THANKS TO:
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 ;; ---------
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
147 ;; 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
148 ;; developing it with their reports. In particular thanks to
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 ;;
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
150 ;; F. Burstall, Alastair Burt, Soren Dayton, Stephen Eglen,
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
151 ;; Karl Eichwalder, Peter Galbraith, Dieter Kraft, Adrian Lanz,
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
152 ;; Rory Molinari, Laurent Mugnier, Sudeep Kumar Palat, Daniel Polani,
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
153 ;; Robin Socha, Richard Stanton, Allan Strand, Jan Vroonhof,
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
154 ;; Christoph Wedler.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 ;;
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
156 ;; The view crossref feature was inspired by the similar function in
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
157 ;; Peter Galbraith's bib-cite.el.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
158 ;;
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
159 ;; Finally thanks to Uwe Bolick who first got me (some years ago) into
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
160 ;; supporting LaTeX labels and references with an Editor (which was
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
161 ;; MicroEmacs at the time).
18219
aaeaae005e98 Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents: 18123
diff changeset
162 ;;
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
163 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
164 ;;
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 ;;; Code:
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
168 (eval-when-compile (require 'cl))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
169
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 ;; Stuff that needs to be there when we use defcustom
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 ;; --------------------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 (require 'custom)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 (defvar reftex-tables-dirty t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 "Flag showing if tables need to be re-computed.")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 (eval-and-compile
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 (defun reftex-set-dirty (symbol value)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 (setq reftex-tables-dirty t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 (set symbol value)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
183 (eval-and-compile
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
184 (defmacro reftex-fp (n)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
185 (if (fboundp 'forward-point)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
186 (list 'forward-point n)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
187 (list '+ '(point) n))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
188
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 ;;; Begin of Configuration Section ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
191 ;; 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
192
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
193 (eval-and-compile
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
194 (defconst reftex-label-alist-builtin
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
195 '(
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
196 ;; Some aliases, mostly for backward compatibility
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
197 (Sideways "Alias for -->rotating" (rotating))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
198 (AMSTeX "amsmath with eqref macro"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
199 ((nil ?e nil "~\\eqref{%s}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
200 amsmath))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
201
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
202 ;; Individual package defaults
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
203 (amsmath "AMS-LaTeX math environments"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
204 (("align" ?e nil nil eqnarray-like)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
205 ("gather" ?e nil nil eqnarray-like)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
206 ("multline" ?e nil nil t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
207 ("flalign" ?e nil nil eqnarray-like)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
208 ("alignat" ?e nil nil alignat-like)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
209 ("xalignat" ?e nil nil alignat-like)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
210 ("xxalignat" ?e nil nil alignat-like)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
211 ("subequations" ?e nil nil t)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
212
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
213 (endnotes "The \\endnote macro"
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
214 (("\\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
215
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
216 (fancybox "The Beqnarray environment"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
217 (("Beqnarray" ?e nil nil eqnarray-like)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
218
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
219 (floatfig "The floatingfigure environment"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
220 (("floatingfigure" ?f nil nil caption)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
221
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
222 (longtable "The longtable environment"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
223 (("longtable" ?t nil nil caption)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
224
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
225 (picinpar "The figwindow and tabwindow environments"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
226 (("figwindow" ?f nil nil 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
227 ("tabwindow" ?f nil nil 1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
228
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
229 (rotating "Sidewaysfigure and table"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
230 (("sidewaysfigure" ?f nil nil caption)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
231 ("sidewaystable" ?t nil nil caption)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
232
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
233 (sidecap "CSfigure and SCtable"
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
234 (("SCfigure" ?f nil nil caption)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
235 ("SCtable" ?t nil nil caption)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
236
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
237 (subfigure "Subfigure environments/macro"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
238 (("subfigure" ?f nil nil caption)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
239 ("subfigure*" ?f nil nil caption)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
240 ("\\subfigure[]{}" ?f nil nil 1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
241
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
242 (supertab "Supertabular environment"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
243 (("supertabular" ?t nil nil "\\tablecaption{")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
244
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
245 (wrapfig "The wrapfigure environment"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
246 (("wrapfigure" ?f nil nil caption)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
247
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
248 ;; The LaTeX core stuff
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
249 (LaTeX "LaTeX default environments"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
250 (("section" ?s "sec:" "~\\ref{%s}" (nil . t)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
251 (regexp "Parts?" "Chapters?" "Chap\\." "Sections?" "Sect?\\."
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
252 "Paragraphs?" "Par\\."
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
253 "\\\\S" "\247" "Teile?" "Kapitel" "Kap\\." "Abschnitte?"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
254 "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
255
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
256 ("enumerate" ?i "item:" "~\\ref{%s}" item
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
257 (regexp "Items?" "Punkte?"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
258
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
259 ("equation" ?e "eq:" "~(\\ref{%s})" t
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
260 (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
261 ("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
262
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
263 ("figure" ?f "fig:" "~\\ref{%s}" caption
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
264 (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
265 ("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
266
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
267 ("table" ?t "tab:" "~\\ref{%s}" caption
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
268 (regexp "Tables?" "Tab\\." "Tabellen?"))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
269 ("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
270
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
271 ("\\footnote[]{}" ?n "note:" "~\\ref{%s}" 2
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
272 (regexp "Footnotes?" "Notes?"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
273
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
274 ("any" ?\ " " "~\\ref{%s}" nil)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
275
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
276 )
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
277 "The default label environment descriptions.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
278 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
279 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
280
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
281 (defconst reftex-cite-format-builtin
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 (default "Default macro \\cite{%l}"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
284 "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
285 (natbib "The Natbib package"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
286 ((?\C-m . "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
287 (?t . "\\citet{%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 (?p . "\\citep{%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 (?e . "\\citep[e.g.][]{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
292 (?a . "\\citeauthor{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
293 (?y . "\\citeyear{%l}")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
294 (harvard "The Harvard package"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
295 ((?\C-m . "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
296 (?p . "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
297 (?t . "\\citeasnoun{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
298 (?n . "\\citeasnoun{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
299 (?s . "\\possessivecite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
300 (?e . "\\citeaffixed{%l}{?}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
301 (?y . "\\citeyear{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
302 (?a . "\\citename{%l}")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
303 (chicago "The Chicago package"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
304 ((?\C-m . "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
305 (?t . "\\citeN{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
306 (?T . "\\shortciteN{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
307 (?p . "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
308 (?P . "\\shortcite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
309 (?a . "\\citeA{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
310 (?A . "\\shortciteA{%l}")
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
311 (?y . "\\citeyear{%l}")))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
312 (astron "The Astron package"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
313 ((?\C-m . "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
314 (?p . "\\cite{%l}" )
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
315 (?t . "%2a (\\cite{%l})")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
316 (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
317 ((?\C-m . "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
318 (?t . "%2a (%y)\\nocite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
319 (?p . "(%2a %y\\nocite{%l})")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
320 (locally "Full info in parenthesis"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
321 "(%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
322 ;; undocumented feature: `%<' kills white space and punctuation locally.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
323 )
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
324 "Builtin versions of for the citation format.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
325 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
326 `?\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
327 `?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
328 `?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
329 )
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
330
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 ;; Configuration Variables and User Options for RefTeX ------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 (defgroup reftex nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 "LaTeX label and citation support."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 :tag "RefTeX"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
336 :link '(url-link :tag "Home Page"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
337 "http://strw.leidenuniv.nl/~dominik/Tools/")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
338 :link '(emacs-commentary-link :tag "Commentary in reftex.el" "reftex.el")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 :prefix "reftex-"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 :group 'tex)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 (defun reftex-customize ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 "Call the customize function with reftex as argument."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 (interactive)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
345 ;; Depending on the customize version we can call different functions.
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
346 (cond
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
347 ((fboundp 'customize-browse)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
348 (customize-browse 'reftex))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
349 ((fboundp 'customize-group)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
350 (customize-group 'reftex))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
351 ((fboundp 'customize)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
352 (customize 'reftex))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
353 (t (error "Custom.el not available"))))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
354
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
355 (defun reftex-create-customize-menu ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
356 "Create a full customization menu for RefTeX."
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
357 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
358 (if (fboundp 'customize-menu-create)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
359 (progn
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
360 (easy-menu-change
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
361 '("Ref") "Customize"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
362 `(["Browse RefTeX group" reftex-customize t]
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
363 "---"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
364 ,(customize-menu-create 'reftex)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
365 ["Set" Custom-set t]
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
366 ["Save" Custom-save t]
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
367 ["Reset to Current" Custom-reset-current t]
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
368 ["Reset to Saved" Custom-reset-saved t]
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
369 ["Reset to Standard Settings" Custom-reset-standard t]))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
370 (message "\"Ref\"-menu now contains full customization menu"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
371 (error "Cannot expand menu (outdated version of cus-edit.el)")))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
372
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
373 (defun reftex-show-commentary ()
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
374 "Use the finder to view the file documentation from `reftex.el'."
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
375 (interactive)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
376 (require 'finder)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
377 (finder-commentary "reftex.el"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
379 (defun reftex-info ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
380 "Read documentation for RefTeX in the info system."
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
381 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
382 (require 'info)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
383 (Info-goto-node "(reftex)"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
384
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
385 ;; Support for \label and \ref --------------------------------------
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 (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
388 "Support for creation, insertion and referencing of labels in LaTeX."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 :group 'reftex)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 (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
392 "Definition of environments and macros to do with label."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393 :group 'reftex-label-support)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
395 ;; Make a constant for the customization stuff
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
396 (eval-and-compile
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
397 (defconst reftex-tmp
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
398 '((const :tag "Default position" t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
399 (const :tag "After label" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
400 (number :tag "Macro arg nr" 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
401 (regexp :tag "Regexp" "")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
402 (const :tag "Caption in float" caption)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
403 (const :tag "Item in list" item)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
404 (const :tag "Eqnarray-like" eqnarray-like)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
405 (const :tag "Alignat-like" alignat-like)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
406 (symbol :tag "Function" my-func))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
407
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
408 (defcustom reftex-default-label-alist-entries
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
409 '(amsmath endnotes fancybox floatfig longtable picinpar
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
410 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
411 "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
412 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
413 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
414
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
415 The options include:
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
416 LaTeX The standard LaTeX environments.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
417 Sideways The sidewaysfigure and sidewaystable environments.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
418 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
419
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
420 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
421
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
422 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
423 :group 'reftex-defining-label-environments
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
424 :set 'reftex-set-dirty
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
425 :type `(set
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
426 :indent 4
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
427 :inline t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
428 :greedy t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
429 ,@(mapcar
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
430 (function
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
431 (lambda (x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
432 (list 'const ':tag (concat (symbol-name (nth 0 x))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
433 ": " (nth 1 x))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
434 (nth 0 x))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
435 reftex-label-alist-builtin)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
436
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437 (defcustom reftex-label-alist nil
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
438 "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
439
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
440 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
441 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
442 `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
443
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
444 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
445 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
446 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
447 places in the code.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
448
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
449 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
450 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
451 one of its arguments. The elements of each list entry are:
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
453 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
454 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
455 \"\\\\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
456 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
457 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
458 its arguments.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459 Special names: `section' for section labels, `any' to define a group
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460 which contains all labels.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
461 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
462 associated with the type indicator character (see below).
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
464 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
465 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
466 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
467 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
468 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
469 `equation' and `eqnarray').
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471 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
472 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
473 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
474 %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
475 %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
476 %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
477
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
478 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
479
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
480 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
481 the label.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
482 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
483 there is not already a whitespace before point.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485 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
486 - 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
487 - If t, use
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488 - 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
489 - 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
490 (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
491 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
492 - 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
493 - 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
494 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
495 - 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
496 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
497 \"\\\\\\\\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
498 environment.
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
499 \"\\\\\\\\begin{eqnarray}\\\\|\\\\\\\\\\\\\\\\\" works for eqnarrays.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
500 - 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
501 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
502 (see also the variable `reftex-default-context-regexps').
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 - 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
504 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
505 function is expected to return a suitable context string. It should
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506 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
507 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
508 the label macro as context:
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510 (defun my-context-function (env-or-mac)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 (if (> (point-max) (+ 10 (point)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 (buffer-substring (point) (+ 10 (point)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 (error \"Buffer too small\")))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
515 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
516 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
517 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
518 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
519 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
520 actually used for section labels.
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
521
18220
36a61aa59b9d (tex-main-file, outline-minor-mode): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents: 18219
diff changeset
522 Setting the variable `reftex-use-text-after-label-as-context' to t
36a61aa59b9d (tex-main-file, outline-minor-mode): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents: 18219
diff changeset
523 overrides the setting here.
36a61aa59b9d (tex-main-file, outline-minor-mode): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents: 18219
diff changeset
524
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
525 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
526 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
527 `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
528 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
529 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
530 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
531 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
532
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533 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
534 will use
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 - the first non-nil format and prefix
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536 - the magic words of all involved entries.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537
18220
36a61aa59b9d (tex-main-file, outline-minor-mode): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents: 18219
diff changeset
538 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
539 `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
540 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
541 `reftex-default-label-alist-entries."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542 :group 'reftex-defining-label-environments
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
543 :set 'reftex-set-dirty
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
544 :type
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
545 `(repeat
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
546 (choice
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
547 :value ("" ?a nil nil nil nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
548 (list :tag "Detailed label alist entry"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
549 :value ("" ?a nil nil nil nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
550 (choice :tag "Environment or \\macro "
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
551 (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
552 (string ""))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
553 (character :tag "Typekey character " ?a)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
554 (choice :tag "Label prefix string "
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
555 (const :tag "Default" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
556 (string :tag "String" "lab:"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
557 (choice :tag "Label reference format"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
558 (const :tag "Default" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
559 (string :tag "String" "~\\ref{%s}"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
560 (choice :tag "Context"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
561 (choice
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
562 :tag "1 method"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
563 ,@reftex-tmp)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
564 (cons :tag "Split methods"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
565 (choice
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
566 :tag " Display context "
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
567 ,@reftex-tmp)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
568 (choice
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
569 :tag " Derive label context"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
570 ,@reftex-tmp)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
571 (repeat :tag "List of Magic Words" (string)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
572 (choice
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
573 :tag "Package"
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
574 :value AMSTeX
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
575 ,@(mapcar
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
576 (function
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
577 (lambda (x)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
578 (list 'const ':tag (concat (symbol-name (nth 0 x)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
579 (nth 0 x))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
580 reftex-label-alist-builtin)))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
582 ;; LaTeX section commands and level numbers
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
583 (defcustom reftex-section-levels
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
584 '(
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
585 ("part" . 0)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
586 ("chapter" . 1)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
587 ("section" . 2)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
588 ("subsection" . 3)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
589 ("subsubsection" . 4)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
590 ("paragraph" . 5)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
591 ("subparagraph" . 6)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
592 ("subsubparagraph" . 7)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
593 )
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
594 "Commands and levels used for defining sections in the document.
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
595 The car of each cons cell is the name of the section macro. The cdr is a
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
596 number indicating its level."
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
597 :group 'reftex-defining-label-environments
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
598 :set 'reftex-set-dirty
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
599 :type '(repeat
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
600 (cons (string :tag "sectioning macro" "")
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
601 (number :tag "level " 0))))
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
602
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
603 (defcustom reftex-default-context-regexps
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
604 '((caption . "\\\\\\(rot\\)?caption\\*?[[{]")
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
605 (item . "\\\\item\\(\\[[^]]*\\]\\)?")
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
606 (eqnarray-like . "\\\\begin{%s}\\|\\\\\\\\")
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
607 (alignat-like . "\\\\begin{%s}{[0-9]*}\\|\\\\\\\\"))
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
608 "Alist with default regular expressions for finding context.
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
609 The form (format regexp (regexp-quote environment)) is used to calculate
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
610 the final regular expression - so %s will be replaced with the environment
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
611 or macro."
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
612 :group 'reftex-defining-label-environments
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
613 :type '(repeat (cons (symbol) (regexp))))
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
614
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
615 (defcustom reftex-use-text-after-label-as-context nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
616 "*t means, grab context from directly after the \\label{..} macro.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
617 This is the fastest method for obtaining context of the label definition, but
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
618 requires discipline when placing labels. Setting this variable to t takes
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
619 precedence over the individual settings in `reftex-label-alist'.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
620 This variable may be set to t, nil, or a string of label type letters
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
621 indicating the label types for which it should be true."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
622 :group 'reftex-defining-label-environments
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
623 :set 'reftex-set-dirty
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
624 :type '(choice
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
625 (const :tag "on" t) (const :tag "off" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
626 (string :tag "Selected label types")))
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 ;; Label insertion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
629
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
630 (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
631 "Options on how to create new labels."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
632 :group 'reftex-label-support)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
633
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
634 (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
635 "Flags governing label insertion. First flag DERIVE, second flag PROMPT.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
636
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
637 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
638 A section label for example will be derived from the section heading.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
639 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
640 specifications given in `reftex-derive-label-parameters'.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
641 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
642 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
643 unique number, like `eq:23'.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
644
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
645 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
646 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
647 context. When PROMPT is nil, the default label will be inserted without
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
648 query.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
649
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
650 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
651 table describing all four possibilities:
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
652
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
653 DERIVE PROMPT ACTION
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
654 -------------------------------------------------------------------------
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
655 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
656 nil t Prompt for label.
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
657 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
658 t t Derive a label from context and prompt for confirmation.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
659
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
660 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
661 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
662 like character classes.
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
663 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
664 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
665 (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
666 without confirmation for everything else.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
667 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
668 e (equation), n (footnote), plus any definitions in `reftex-label-alist'."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
669 :group 'reftex-making-and-inserting-labels
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670 :type '(list (choice :tag "Derive label from context"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
671 (const :tag "always" t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
672 (const :tag "never" nil)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
673 (string :tag "selected label types" ""))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
674 (choice :tag "Prompt for label string "
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
675 :entry-format " %b %v"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
676 (const :tag "always" t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
677 (const :tag "never" nil)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
678 (string :tag "selected label types" ""))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
679
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
680 (defcustom reftex-derive-label-parameters '(3 20 t 1 "-"
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
681 ("the" "on" "in" "off" "a" "for" "by" "of" "and" "is"))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
682 "Parameters for converting a string into a label.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
683 NWORDS Number of words to use.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
684 MAXCHAR Maximum number of characters in a label string.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
685 ILLEGAL nil: Throw away any words containing characters illegal in labels.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
686 t: Throw away only the illegal characters, not the whole word.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
687 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
688 t: Always abbreviate words (see `reftex-abbrev-parameters').
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
689 not t and not nil: Abbreviate words if necessary to shorten
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
690 label string below MAXCHAR.
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
691 SEPARATOR String separating different words in the label.
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
692 IGNOREWORDS List of words which should not be part of labels."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
693 :group 'reftex-making-and-inserting-labels
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
694 :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
695 (integer :tag "Maximum label length " 20)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
696 (choice :tag "Illegal characters in words"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
697 (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
698 (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
699 (choice :tag "Abbreviate words "
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
700 (const :tag "never" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
701 (const :tag "always" t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
702 (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
703 (string :tag "Separator between words " "-")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
704 (repeat :tag "Ignore words"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
705 :entry-format " %i %d %v"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
706 (string :tag ""))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
707
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
708 (defcustom reftex-label-illegal-re "[\000-\040\177-\377\\\\#$%&~^_{}]"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
709 "Regexp matching characters not legal in labels.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
710 For historic reasons, this character class comes *with* the [] brackets."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
711 :group 'reftex-making-and-inserting-labels
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
712 :type '(regexp :tag "Character class"))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
713
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
714 (defcustom reftex-abbrev-parameters '(4 2 "^saeiou" "aeiou")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
715 "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
716 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
717 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
718 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
719 AFTER Character class after abbrev point in word."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
720 :group 'reftex-making-and-inserting-labels
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
721 :type '(list
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
722 (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
723 (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
724 (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
725 (string :tag "cut after char class " "aeiou")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
726
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
727 (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
728 "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
729 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
730 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
731 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
732 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
733 :group 'reftex-making-and-inserting-labels
21892
f718f5a51f59 C. Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21170
diff changeset
734 :version "20.3"
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
735 :type 'function)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
736
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
737 ;; Label referencing
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
738
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
739 (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
740 "Options on how to reference labels."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
741 :group 'reftex-label-support)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
742
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
743 (eval-and-compile
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
744 (defconst reftex-tmp
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
745 '((const :tag "on" t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
746 (const :tag "off" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
747 (string :tag "Selected label types"))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
748
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
749 (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
750 "List of flags governing the label menu makeup.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
751 The flags are:
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
752
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
753 TABLE-OF-CONTENTS Show the labels embedded in a table of context.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
754 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
755 COUNTERS Show counters. This just numbers the labels in the menu.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
756 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
757 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
758 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
759 MATCH-IN-TOC Obsolete flag.
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
760 SHOW FILES Show begin and end of included files.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
761
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
762 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
763 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
764 like character classes in regular expressions. Thus, setting one of the
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
765 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
766 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
767 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
768 e (equation), n (footnote), plus any definitions in `reftex-label-alist'.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
769
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
770 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
771 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
772 get one interactively during selection from the label menu."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
773 :group 'reftex-referencing-labels
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
774 :type
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
775 `(list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
776 (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
777 (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
778 (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
779 (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
780 (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
781 (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
782 (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
783 (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
784
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
785 (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
786 "*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
787 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
788 `\\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
789 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
790 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
791 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
792 :group 'reftex-referencing-labels
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
793 :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
794
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
795 (defcustom reftex-level-indent 2
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
796 "*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
797 :group 'reftex-referencing-labels
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
798 :type '(integer))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
799
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
800 (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
801 "*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
802 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
803 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
804 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
805 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
806 :group 'reftex-referencing-labels
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
807 :type '(boolean))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
808
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
809 (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
810 "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
811 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
812 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
813 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
814 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
815 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
816 :group 'reftex-referencing-labels
21892
f718f5a51f59 C. Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21170
diff changeset
817 :version "20.3"
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
818 :type 'function)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
819
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
820 ;; BibteX citation configuration ----------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
821
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
822 (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
823 "Support for referencing bibliographic data with BibTeX."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
824 :group 'reftex)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
825
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
826 (defcustom reftex-bibpath-environment-variables '("BIBINPUTS" "TEXBIB")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
827 "*List of env vars which might contain the path to BibTeX database files."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
828 :group 'reftex-citation-support
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
829 :set 'reftex-set-dirty
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
830 :type '(repeat (string :tag "Environment variable")))
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 (defcustom reftex-bibfile-ignore-list nil
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
833 "*List of files in \\bibliography{..} RefTeX should *not* parse.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
834 The file names have to be in the exact same form as in the bibliography
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
835 macro - i.e. without the `.bib' extension.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
836 Intended for files which contain only `@string' macro definitions and the
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
837 like, which are ignored by RefTeX anyway."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
838 :group 'reftex-citation-support
21892
f718f5a51f59 C. Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21170
diff changeset
839 :version "20.3"
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
840 :set 'reftex-set-dirty
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
841 :type '(repeat (string :tag "File name")))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
842
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
843 (defcustom reftex-default-bibliography nil
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
844 "*List of BibTeX database file which should be used if none are specified.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
845 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
846 `\bibliography{..}' statement nor a `thebibliography' environment,
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
847 RefTeX will scan these files instead. Intended for using
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
848 `reftex-citation' in non-LaTeX files."
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
849 :group 'reftex-citation-support
21892
f718f5a51f59 C. Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21170
diff changeset
850 :version "20.3"
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
851 :type '(repeat (file)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
852
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
853 (defcustom reftex-sort-bibtex-matches 'reverse-year
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
854 "*Sorting of the entries found in BibTeX databases by reftex-citation.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
855 Possible values:
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
856 nil Do not sort entries.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
857 'author Sort entries by author name.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
858 'year Sort entries by increasing year.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
859 'reverse-year Sort entries by decreasing year."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
860 :group 'reftex-citation-support
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
861 :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
862 (const :tag "by author" author)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
863 (const :tag "by year" year)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
864 (const :tag "by year, reversed" reverse-year)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
865
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
866 (defcustom reftex-cite-format 'default
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
867 "*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
868 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
869 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
870 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
871
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
872 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
873 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
874
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
875 %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
876 %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
877 %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
878 %A First author name only.
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
879 %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
880
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
881 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
882 %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
883 %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
884 %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
885 %r address %s school %u publisher %t title
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
886 %v volume %y year
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
887
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
888 Usually, only %l is needed. Try, however, (setq reftex-comment-citations t).
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
889
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
890 Beware that all this only works when using BibTeX database files. When
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
891 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
892 environment, only %l is available.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
893
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
894 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
895 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
896 strings.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
897 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
898 `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
899 the predefined styles (see `reftex-cite-format-builtin'). E.g.:
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
900 (setq reftex-cite-format 'harvard)"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
901 :group 'reftex-citation-support
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
902 :type
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
903 `(choice
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
904 :format "%{%t%}: \n%[Value Menu%] %v"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
905 (radio :tag "Symbolic Builtins"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
906 :indent 4
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
907 :value default
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
908 ,@(mapcar
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
909 (function
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
910 (lambda (x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
911 (list 'const ':tag (concat (symbol-name (nth 0 x))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
912 ": " (nth 1 x))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
913 (nth 0 x))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
914 reftex-cite-format-builtin))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
915 (string :tag "format string" "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
916 (repeat :tag "key-ed format strings"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
917 :value ((?\r . "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
918 (?t . "\\cite{%l}") (?p . "\\cite{%l}"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
919 (cons (character :tag "Key character" ?\r)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
920 (string :tag "Format string" "")))))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
921
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
922 (defcustom reftex-comment-citations nil
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
923 "*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
924 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
925 :group 'reftex-citation-support
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
926 :type '(boolean))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
927
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
928 (defcustom reftex-cite-comment-format
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
929 "%% %2a %y, %j %v, %P, %e: %b, %u, %s %<\n"
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
930 "Citation format used for commented citations. Must NOT contain %l."
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
931 :group 'reftex-citation-support
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
932 :type '(string))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
933
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
934 (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
935 "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
936 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
937 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
938 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
939 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
940 :group 'reftex-citation-support
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
941 :type '(list
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
942 (string :tag "Separator for names ")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
943 (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
944 (string :tag "string used as et al. ")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
945
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
946 (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
947 "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
948 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
949 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
950 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
951 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
952 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
953 :group 'reftex-citation-support
21892
f718f5a51f59 C. Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21170
diff changeset
954 :version "20.3"
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
955 :type 'function)
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
956
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
957 ;; Table of contents configuration --------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
958
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
959 (defgroup reftex-table-of-contents-browser nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
960 "A multifile table of contents browser."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
961 :group 'reftex)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
962
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
963 (defcustom reftex-toc-follow-mode nil
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
964 "*Non-nil means, point in *toc* buffer will cause other window to follow.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
965 The other window will show the corresponding part of the document.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
966 This flag can be toggled from within the *toc* buffer with the `f' key."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
967 :group 'reftex-table-of-contents-browser
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
968 :type '(boolean))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
969
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
970 ;; Tuning the parser ----------------------------------------------------
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
971
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
972 (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
973 "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
974 :group 'reftex)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
975
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
976 (defcustom reftex-keep-temporary-buffers 1
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
977 "*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
978 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
979 We distinguish files visited for
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
980 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
981 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
982 to display label context, etc.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
983 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
984 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
985
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
986 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
987 t Keep everything.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
988 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
989 for lookup.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
990
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
991 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
992 slow but will happen only once).
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
993 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
994 upon the variable `reftex-initialize-temporary-buffers'."
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
995 :group 'reftex-miscellaneous-configurations
21892
f718f5a51f59 C. Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21170
diff changeset
996 :version "20.3"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
997 :type '(choice
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
998 (const :tag "Throw away everything" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
999 (const :tag "Keep everything" t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1000 (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
1001
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1002 (defcustom reftex-initialize-temporary-buffers nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1003 "*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
1004 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
1005 visit a file.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1006 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
1007 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
1008 do a minimal initialization."
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1009 :group 'reftex-miscellaneous-configurations
21892
f718f5a51f59 C. Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21170
diff changeset
1010 :version "20.3"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1011 :type '(choice
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1012 (const :tag "Read files literally" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1013 (const :tag "Fully initialize buffers" t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1014 (repeat :tag "Hook functions" :value (nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1015 (function-item))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1016
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1017 (defcustom reftex-no-include-regexps '("\\.pstex_t\\'") ; default for x-symbol
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1018 "*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
1019 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
1020 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
1021 :group 'reftex-optimizations-for-large-documents
21892
f718f5a51f59 C. Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21170
diff changeset
1022 :version "20.3"
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1023 :type '(repeat (regexp)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1024
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1025 (defcustom reftex-enable-partial-scans nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1026 "*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
1027 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
1028 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
1029 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
1030 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
1031 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
1032 in menus."
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1033 :group 'reftex-optimizations-for-large-documents
21892
f718f5a51f59 C. Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21170
diff changeset
1034 :version "20.3"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1035 :type 'boolean)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1036
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1037 (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
1038 "*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
1039 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
1040 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
1041 list."
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1042 :group 'reftex-optimizations-for-large-documents
21892
f718f5a51f59 C. Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21170
diff changeset
1043 :version "20.3"
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1044 :type 'boolean)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1045
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1046 (defcustom reftex-save-parse-info nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1047 "*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
1048 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
1049 information. When this variable is t,
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1050 - 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
1051 will read that file (if available) instead of parsing the document.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1052 - each time (part of) the document is rescanned, a new version of the file
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1053 is written."
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1054 :group 'reftex-optimizations-for-large-documents
21892
f718f5a51f59 C. Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21170
diff changeset
1055 :version "20.3"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1056 :type 'boolean)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1057
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1058 (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
1059 "*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
1060 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
1061 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
1062 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
1063 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
1064 `reftex-auto-update-selection-buffers'."
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1065 :group 'reftex-optimizations-for-large-documents
21892
f718f5a51f59 C. Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21170
diff changeset
1066 :version "20.3"
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1067 :type 'boolean)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1068
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1069 (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
1070 "*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
1071 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
1072 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
1073 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
1074 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
1075 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
1076 `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
1077 :group 'reftex-optimizations-for-large-documents
21892
f718f5a51f59 C. Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21170
diff changeset
1078 :version "20.3"
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1079 :type 'boolean)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1080
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1081 ;; Fontification and Faces ----------------------------------------------
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1082
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1083 (defgroup reftex-fontification-configurations nil
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1084 "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
1085 :group 'reftex)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1086
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1087 (defcustom reftex-use-fonts t
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1088 "*Non-nil means, use fonts in *toc* and selection buffers.
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1089 Font-lock must be loaded as well to actually get fontified display."
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1090 :group 'reftex-fontification-configurations
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1091 :type '(boolean))
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1092
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1093 (defcustom reftex-refontify-context 1
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1094 "*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
1095 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
1096 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
1097
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1098 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
1099 nil Never refontify.
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1100 t Always refontify.
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1101 1 Refontify when absolutely necessary, e.g. when with the x-symbol package.
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1102 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
1103 :group 'reftex-fontification-configurations
21892
f718f5a51f59 C. Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21170
diff changeset
1104 :version "20.3"
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1105 :type '(choice
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1106 (const :tag "Never" nil)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1107 (const :tag "Always" t)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1108 (const :tag "When necessary" 1)))
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1109
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1110 (defcustom reftex-highlight-selection 'cursor
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1111 "*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
1112 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
1113 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
1114 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
1115 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
1116 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
1117
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1118 nil No highlighting.
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1119 cursor Highlighting is cursor driven.
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1120 mouse Highlighting is mouse driven.
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1121 both Both cursor and mouse trigger highlighting."
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1122 :group 'reftex-fontification-configurations
21892
f718f5a51f59 C. Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21170
diff changeset
1123 :version "20.3"
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1124 :type '(choice
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1125 (const :tag "Never" nil)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1126 (const :tag "Cursor driven" cursor)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1127 (const :tag "Mouse driven" mouse)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1128 (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
1129
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1130 (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
1131 "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
1132 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
1133 :group 'reftex-fontification-configurations
21892
f718f5a51f59 C. Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21170
diff changeset
1134 :version "20.3"
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1135 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1136 (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
1137 "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
1138 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
1139 :group 'reftex-fontification-configurations
21892
f718f5a51f59 C. Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21170
diff changeset
1140 :version "20.3"
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1141 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1142 (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
1143 "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
1144 :group 'reftex-fontification-configurations
21892
f718f5a51f59 C. Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21170
diff changeset
1145 :version "20.3"
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1146 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1147 (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
1148 "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
1149 :group 'reftex-fontification-configurations
21892
f718f5a51f59 C. Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21170
diff changeset
1150 :version "20.3"
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1151 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1152 (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
1153 "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
1154 :group 'reftex-fontification-configurations
21892
f718f5a51f59 C. Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21170
diff changeset
1155 :version "20.3"
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1156 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1157 (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
1158 "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
1159 :group 'reftex-fontification-configurations
21892
f718f5a51f59 C. Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21170
diff changeset
1160 :version "20.3"
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1161 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1162 (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
1163 "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
1164 :group 'reftex-fontification-configurations
21892
f718f5a51f59 C. Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21170
diff changeset
1165 :version "20.3"
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1166 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1167 (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
1168 "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
1169 :group 'reftex-fontification-configurations
21892
f718f5a51f59 C. Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21170
diff changeset
1170 :version "20.3"
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1171 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1172 (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
1173 "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
1174 :group 'reftex-fontification-configurations
21892
f718f5a51f59 C. Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21170
diff changeset
1175 :version "20.3"
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1176 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1177 (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
1178 "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
1179 :group 'reftex-fontification-configurations
21892
f718f5a51f59 C. Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21170
diff changeset
1180 :version "20.3"
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1181 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1182
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1183 ;; Miscellaneous configurations -----------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1184
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1185 (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
1186 "Collection of further configurations."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1187 :group 'reftex)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1188
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1189 (defcustom reftex-extra-bindings nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1190 "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
1191 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
1192 :group 'reftex-miscellaneous-configurations
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1193 :type '(boolean))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1194
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1195 (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
1196 "*Plug-in flags for AUCTeX interface.
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1197 This variable is a list of 4 boolean flags. When a flag is non-nil, it
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1198 means:
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1199
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1200 Flag 1: use `reftex-label' as `LaTeX-label-function'.
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1201 Flag 2: use `reftex-arg-label' as `TeX-arg-label'
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1202 Flag 3: use `reftex-arg-ref' as `TeX-arg-ref'
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1203 Flag 4: use `reftex-arg-cite' as `TeX-arg-cite'
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1204
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1205 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
1206 plug-ins on or off, respectively.
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1207 \\<LaTeX-mode-map>`LaTeX-label-function' is the function used for label insertion when you
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1208 enter a new environment in AUCTeX with \\[LaTeX-environment].
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1209 The `TeX-arg-label' etc. functions are for entering macro arguments during
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1210 macro insertion with \\[TeX-insert-macro].
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1211 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
1212 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
1213 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
1214 :group 'reftex-miscellaneous-configurations
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1215 :type '(choice (const :tag "No plug-ins" nil)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1216 (const :tag "All possible plug-ins" t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1217 (list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1218 :tag "Individual choice"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1219 :value (nil nil nil nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1220 (boolean :tag "Use reftex-label as LaTeX-label-function")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1221 (boolean :tag "Use reftex-arg-label as TeX-arg-label ")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1222 (boolean :tag "Use reftex-arg-ref as TeX-arg-ref ")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1223 (boolean :tag "Use reftex-arg-cite as TeX-arg-cite ")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1224 )))
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1225
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1226 (defcustom reftex-auto-show-entry 'copy
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1227 "*Non-nil means, do something when context in other window is hidden.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1228 Some modes like `outline-mode' or `folding-mode' hide parts of buffers.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1229 When RefTeX is asked to show context for a label definition, and the context
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1230 is invisible, it can unhide that section permanently (value t), or copy the
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1231 context to a temporary buffer (value 'copy)."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1232 :group 'reftex-miscellaneous-configurations
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1233 :type '(radio :value copy
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1234 :indent 4
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1235 (const :tag "Do nothing" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1236 (const :tag "Unhide section permanently" t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1237 (const :tag "Copy context to show" copy)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1238
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1239 (defcustom reftex-revisit-to-follow t
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1240 "*Non-nil means, follow-mode will revisit files if necessary.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1241 When nil, follow-mode will be suspended for stuff in unvisited files."
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1242 :group 'reftex-miscellaneous-configurations
21892
f718f5a51f59 C. Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21170
diff changeset
1243 :version "20.3"
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1244 :type '(boolean))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1245
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1246 (defcustom reftex-load-hook nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1247 "Hook which is being run when loading reftex.el."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1248 :group 'reftex-miscellaneous-configurations
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1249 :type 'hook)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1250
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1251 (defcustom reftex-mode-hook nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1252 "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
1253 :group 'reftex-miscellaneous-configurations
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1254 :type 'hook)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1255
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1256 ;;; End of Configuration Section ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1257
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1258 ;;;===========================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1259 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1260 ;;; Define the formal stuff for a minor mode named RefTeX.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1261 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1262
21130
60e882bbb28b Added keybinding for `reftex-mouse-view-crossref' to S-mouse-2.
Carsten Dominik <dominik@science.uva.nl>
parents: 21124
diff changeset
1263 ;; This file corresponds to RefTeX version 3.22
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
1264
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1265 (defvar reftex-mode nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1266 "Determines if RefTeX minor mode is active.")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1267 (make-variable-buffer-local 'reftex-mode)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1268
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1269 (defvar reftex-mode-map (make-sparse-keymap)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1270 "Keymap for RefTeX minor mode.")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1271
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1272 (defvar reftex-mode-menu nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1273
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1274 ;;;###autoload
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1275 (defun turn-on-reftex ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1276 "Turn on RefTeX minor mode."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1277 (reftex-mode t))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1278
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1279 ;;;###autoload
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1280 (defun reftex-mode (&optional arg)
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
1281 "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
1282
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1283 Labels can be created with `\\[reftex-label]' and referenced with `\\[reftex-reference]'.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1284 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
1285 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
1286 \\ref macro.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1287
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1288 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
1289 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
1290 database. The selected citation is inserted as a \\cite macro.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1291
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1292 A Table of Contents of the entire (multifile) document with browsing
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1293 capabilities is available with `\\[reftex-toc]'.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1294
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1295 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
1296 pressing `?' to any prompt mentioning this feature.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1297
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1298 Extensive documentation about RefTeX is in the file header of `reftex.el'.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1299 You can view this information with `\\[reftex-show-commentary]'.
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1300
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1301 \\{reftex-mode-map}
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1302 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
1303 on the menu bar.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1304
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1305 ------------------------------------------------------------------------------"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1306
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1307 (interactive "P")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1308 (setq reftex-mode (not (or (and (null arg) reftex-mode)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1309 (<= (prefix-numeric-value arg) 0))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1310
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1311 ; Add or remove the menu, and run the hook
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1312 (if reftex-mode
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1313 (progn
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1314 (easy-menu-add reftex-mode-menu)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1315 (reftex-plug-into-AUCTeX)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1316 (run-hooks 'reftex-mode-hook))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1317 (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
1318
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1319 (or (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
1320 (push '(reftex-mode " Ref") minor-mode-alist))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1321
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1322 (or (assoc 'reftex-mode minor-mode-map-alist)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1323 (push (cons 'reftex-mode reftex-mode-map) minor-mode-map-alist))
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1324
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1325 ;;; ===========================================================================
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1326 ;;;
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1327 ;;; 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
1328 (defvar TeX-master)
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1329 (defvar LaTeX-label-function)
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1330 (defvar tex-main-file)
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1331 (defvar outline-minor-mode)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1332 (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
1333 (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
1334
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1335 ;;; ===========================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1336 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1337 ;;; Interfaces for other packages
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1338 ;;; -----------------------------
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 ;;; AUCTeX
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1341 ;;; ------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1342
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1343 (defun reftex-arg-label (optional &optional prompt definition)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1344 "Use `reftex-label' to create label. Insert it with `TeX-argument-insert'.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1345 This function is intended for AUCTeX macro support."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1346 (let ((label (reftex-label nil t)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1347 (if (and definition (not (string-equal "" label)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1348 (LaTeX-add-labels label))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1349 (TeX-argument-insert label optional optional)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1350
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1351 (defun reftex-arg-ref (optional &optional prompt definition)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1352 "Use `reftex-reference' to select label. Insert with `TeX-argument-insert'.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1353 This function is intended for AUCTeX macro support."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1354 (let ((label (reftex-reference nil t)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1355 (if (and definition (not (string-equal "" label)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1356 (LaTeX-add-labels label))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1357 (TeX-argument-insert label optional optional)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1358
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1359 (defun reftex-arg-cite (optional &optional prompt definition)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1360 "Use reftex-citation to select a key. Insert with `TeX-argument-insert'.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1361 This function is intended for AUCTeX macro support."
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1362 (let ((key (reftex-citation t)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1363 (TeX-argument-insert (or key "") optional optional)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1364
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1365 (defun reftex-plug-into-AUCTeX ()
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1366 ;; Replace AUCTeX functions with RefTeX functions.
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1367 ;; Which functions are replaced is controlled by the variable
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1368 ;; `reftex-plug-into-AUCTeX'.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1369 (let ((flags
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1370 (cond ((eq reftex-plug-into-AUCTeX t) '(t t t t))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1371 ((eq reftex-plug-into-AUCTeX nil) '(nil nil nil nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1372 (t reftex-plug-into-AUCTeX))))
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1373
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1374 (and (nth 0 flags)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1375 (boundp 'LaTeX-label-function)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1376 (setq LaTeX-label-function 'reftex-label))
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1377
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1378 (and (nth 1 flags)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1379 (fboundp 'TeX-arg-label)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1380 (fset 'TeX-arg-label 'reftex-arg-label))
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1381
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1382 (and (nth 2 flags)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1383 (fboundp 'TeX-arg-ref)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1384 (fset 'TeX-arg-ref 'reftex-arg-ref))
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1385
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1386 (and (nth 3 flags)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1387 (fboundp 'TeX-arg-cite)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1388 (fset 'TeX-arg-cite 'reftex-arg-cite))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1389
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1390
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1391 (defvar reftex-label-alist-external-add-ons nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1392 "List of label alist entries added with reftex-add-to-label-alist.")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1393
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1394 (defun reftex-add-to-label-alist (entry-list)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1395 "Add label environment descriptions to `reftex-label-alist-external-add-ons'.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1396 The format of ENTRY-LIST is exactly like `reftex-label-alist'. See there
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1397 for details.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1398 This function makes it possible to support RefTeX from AUCTeX style files.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1399 The entries in ENTRY-LIST will be processed after the user settings in
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1400 `reftex-label-alist', and before the defaults (specified in
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1401 `reftex-default-label-alist-entries'). Any changes made to
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1402 `reftex-label-alist-external-add-ons' will raise a flag to the effect that a
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1403 mode reset is done on the next occasion."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1404 (let (entry)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1405 (while entry-list
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1406 (setq entry (car entry-list)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1407 entry-list (cdr entry-list))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1408 (unless (member entry reftex-label-alist-external-add-ons)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1409 (setq reftex-tables-dirty t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1410 (push entry reftex-label-alist-external-add-ons)))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1411
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1412 ;;; ===========================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1413 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1414 ;;; Multifile support
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 ;;; Technical notes: Multifile works as follows: We keep just one list
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1417 ;;; 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
1418 ;;; `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
1419 ;;; 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
1420 ;;; document. Each buffer has local variables which point to these symbols.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1421
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1422 ;; List of variables which handle the multifile stuff.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1423 ;; This list is used to tie, untie, and reset these symbols.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1424 (defconst reftex-multifile-symbols
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1425 '(reftex-docstruct-symbol))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1426
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1427 ;; Alist connecting master file names with the corresponding lisp symbols.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1428 (defvar reftex-master-index-list nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1429
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1430 ;; Last index used for a master file.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1431 (defvar reftex-multifile-index 0)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1432
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1433 ;; 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
1434 (defvar reftex-docstruct-symbol nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1435 (make-variable-buffer-local 'reftex-docstruct-symbol)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1436
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1437 (defun reftex-next-multifile-index ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1438 ;; 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
1439 (incf reftex-multifile-index))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1440
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1441 (defun reftex-tie-multifile-symbols ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1442 ;; Tie the buffer-local symbols to globals connected with the master file.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1443 ;; 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
1444
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1445 (let* ((master (file-truename (reftex-TeX-master-file)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1446 (index (assoc master reftex-master-index-list))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1447 (symlist reftex-multifile-symbols)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1448 (symbol nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1449 (symname nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1450 (newflag nil))
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1451 ;; Find the correct index.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1452 (if index
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1453 ;; symbols do exist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1454 (setq index (cdr index))
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1455 ;; Get a new index and add info to the alist.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1456 (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
1457 newflag t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1458 (push (cons master index) reftex-master-index-list))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1459
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1460 ;; Get/create symbols and tie them.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1461 (while symlist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1462 (setq symbol (car symlist)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1463 symlist (cdr symlist)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1464 symname (symbol-name symbol))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1465 (set symbol (intern (concat symname "-" (int-to-string index))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1466 (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
1467 ;; Initialize if new symbols.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1468 (if newflag (set (symbol-value symbol) nil)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1469
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1470 ;; 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
1471 (not newflag)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1472
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1473 (defun reftex-untie-multifile-symbols ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1474 ;; Remove ties from multifile symbols, so that next use makes new ones.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1475 (let ((symlist reftex-multifile-symbols)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1476 (symbol nil))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1477 (while symlist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1478 (setq symbol (car symlist)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1479 symlist (cdr symlist))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1480 (set symbol nil))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1481
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1482 (defun reftex-TeX-master-file ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1483 ;; Return the name of the master file associated with the current buffer.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1484 ;; When AUCTeX is loaded, we will use it's more sophisticated method.
18219
aaeaae005e98 Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents: 18123
diff changeset
1485 ;; 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
1486 ;; variable tex-main-file.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1487 (let
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1488 ((master
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1489 (cond
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1490 ((fboundp 'TeX-master-file) ; AUCTeX is loaded. Use its mechanism.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1491 (TeX-master-file t))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1492 ((boundp 'TeX-master) ; The variable is defined - lets use it.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1493 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1494 ((eq TeX-master t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1495 (buffer-file-name))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1496 ((eq TeX-master 'shared)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1497 (setq TeX-master (read-file-name "Master file: "
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1498 nil nil t nil)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1499 (TeX-master)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1500 (t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1501 (setq TeX-master (read-file-name "Master file: "
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1502 nil nil t nil)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1503 ((boundp 'tex-main-file)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1504 ;; This is the variable from the default TeX modes.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1505 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1506 ((stringp tex-main-file)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1507 ;; ok, this must be it
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1508 tex-main-file)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1509 (t
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1510 ;; In this case, the buffer is its own master.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1511 (buffer-file-name))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1512 (t
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1513 ;; Know nothing about master file. Assume this is a master file.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1514 (buffer-file-name)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1515 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1516 ((null master)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1517 (error "Need a filename for this buffer. Please save it first."))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1518 ((or (file-exists-p master)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1519 (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
1520 ;; 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
1521 )
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1522 ((or (file-exists-p (concat master ".tex"))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1523 (reftex-get-buffer-visiting (concat master ".tex")))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1524 ;; Ahh, an extra .tex was missing...
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1525 (setq master (concat master ".tex")))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1526 (t
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1527 ;; Something is wrong here. Throw an exception.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1528 (buffer-file-name)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1529 ; (error "No such master file %s" master)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1530 (expand-file-name master)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1531
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1532 (defun reftex-parse-one ()
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1533 "Re-parse this file."
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1534 (interactive)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1535 (let ((reftex-enable-partial-scans t))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1536 (reftex-access-scan-info '(4))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1537
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1538 (defun reftex-parse-all ()
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1539 "Re-parse entire document."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1540 (interactive)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1541 (reftex-access-scan-info '(16)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1542
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1543 (defun reftex-all-document-files (&optional relative)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1544 ;; Return a list of all files belonging to the current document.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1545 ;; When RELATIVE is non-nil, give file names relative to directory
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1546 ;; of master file.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1547 (let* ((all (symbol-value reftex-docstruct-symbol))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1548 (master-dir (file-name-directory (reftex-TeX-master-file)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1549 (re (concat "\\`" (regexp-quote master-dir)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1550 file-list tmp file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1551 (while (setq tmp (assoc 'bof all))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1552 (setq file (nth 1 tmp)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1553 all (cdr (memq tmp all)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1554 (and relative
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1555 (string-match re file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1556 (setq file (substring file (match-end 0))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1557 (push file file-list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1558 (nreverse file-list)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1559
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1560 (defun reftex-create-tags-file ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1561 "Create TAGS file by running `etags' on the current document.
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1562 The TAGS file is also immediately visited with `visit-tags-table'."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1563 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1564 (reftex-access-scan-info current-prefix-arg)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1565 (let* ((master (reftex-TeX-master-file))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1566 (files (reftex-all-document-files))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1567 (cmd (format "etags %s" (mapconcat 'identity files " "))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1568 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1569 (set-buffer (reftex-get-buffer-visiting master))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1570 (message "Running etags to create TAGS file...")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1571 (shell-command cmd)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1572 (visit-tags-table "TAGS"))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1573
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1574 ;; History of grep commands.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1575 (defvar reftex-grep-history nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1576 (defvar reftex-grep-command "grep -n "
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1577 "Last grep command used in \\[reftex-grep-document]; default for next grep.")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1578
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1579 (defun reftex-grep-document (grep-cmd)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1580 "Run grep query through all files related to this document.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1581 With prefix arg, force to rescan document.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1582 This works also without an active TAGS table."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1583
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1584 (interactive
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1585 (list (read-from-minibuffer "Run grep on document (like this): "
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1586 reftex-grep-command nil nil
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1587 'reftex-grep-history)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1588 (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
1589 (let* ((files (reftex-all-document-files t))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1590 (cmd (format
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1591 "%s %s" grep-cmd
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1592 (mapconcat 'identity files " "))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1593 (grep cmd)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1594
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1595 (defun reftex-search-document (&optional regexp)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1596 "Regexp search through all files of the current TeX document.
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1597 Starts always in the master file. Stops when a match is found.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1598 To continue searching for next match, use command \\[tags-loop-continue].
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1599 This works also without an active TAGS table."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1600 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1601 (let ((default (reftex-this-word)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1602 (unless regexp
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1603 (setq regexp (read-string (format "Search regexp in document [%s]: "
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1604 default))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1605 (if (string= regexp "") (setq regexp (regexp-quote default)))
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 (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
1608 (tags-search regexp (list 'reftex-all-document-files))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1609
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1610 (defun reftex-query-replace-document (&optional from to delimited)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1611 "Run a query-replace-regexp of FROM with TO over the entire TeX document.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1612 Third arg DELIMITED (prefix arg) means replace only word-delimited matches.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1613 If you exit (\\[keyboard-quit] or ESC), you can resume the query replace
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1614 with the command \\[tags-loop-continue].
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1615 This works also without an active TAGS table."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1616 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1617 (let ((default (reftex-this-word)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1618 (unless from
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1619 (setq from (read-string (format "Replace regexp in document [%s]: "
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1620 default)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1621 (if (string= from "") (setq from (regexp-quote default))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1622 (unless to
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1623 (setq to (read-string (format "Replace regexp %s with: " from))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1624 (reftex-access-scan-info current-prefix-arg)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1625 (tags-query-replace from to (or delimited current-prefix-arg)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1626 (list 'reftex-all-document-files))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1627
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1628 (defun reftex-change-label (&optional from to)
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
1629 "Query replace FROM with TO in all \\label and \\ref commands.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1630 Works on the entire multifile document.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1631 If you exit (\\[keyboard-quit] or ESC), you can resume the query replace
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1632 with the command \\[tags-loop-continue].
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1633 This works also without an active TAGS table."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1634 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1635 (let ((default (reftex-this-word "-a-zA-Z0-9_*.:")))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1636 (unless from
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1637 (setq from (read-string (format "Replace label globally [%s]: "
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1638 default))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1639 (if (string= from "") (setq from default))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1640 (unless to
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1641 (setq to (read-string (format "Replace label %s with: "
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1642 from))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1643 (reftex-query-replace-document
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1644 (concat "\\\\\\(label\\|[a-z]*ref\\){" (regexp-quote from) "}")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1645 (format "\\\\\\1{%s}" to))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1646
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1647 (defun reftex-save-all-document-buffers ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1648 "Save all documents associated with the current document.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1649 The function is useful after a global action like replacing or renumbering
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1650 labels."
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1651 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1652 (let ((files (reftex-all-document-files))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1653 file buffer)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1654 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1655 (while (setq file (pop files))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1656 (setq buffer (reftex-get-buffer-visiting file))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1657 (when buffer
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1658 (set-buffer buffer)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1659 (save-buffer))))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1660
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1661 ;;; ===========================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1662 ;;;
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1663 ;;; Functions to create and reference automatic labels.
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1664
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1665 ;; 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
1666
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1667 ;; Prompt used for label type queries directed to the user.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1668 (defconst reftex-type-query-prompt nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1669
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1670 ;; Help string for label type queries.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1671 (defconst reftex-type-query-help nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1672
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1673 ;; Alist relating label type to reference format.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1674 (defconst reftex-typekey-to-format-alist nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1675
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1676 ;; Alist relating label type to label affix.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1677 (defconst reftex-typekey-to-prefix-alist nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1678
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1679 ;; Alist relating environments or macros to label type and context regexp.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1680 (defconst reftex-env-or-mac-alist nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1681
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1682 ;; List of macros carrying a label.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1683 (defconst reftex-label-mac-list nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1684
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1685 ;; List of environments carrying a label.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1686 (defconst reftex-label-env-list nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1687
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1688 ;; List of all typekey letters in use.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1689 (defconst reftex-typekey-list nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1690
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1691 ;; Alist relating magic words to a label type.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1692 (defconst reftex-words-to-typekey-alist nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1693
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1694 ;; The last list-of-labels entry used in a reference.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1695 (defvar reftex-last-used-reference (list nil nil nil nil))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1696
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1697 ;; The regular expression used to abbreviate words.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1698 (defconst reftex-abbrev-regexp
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1699 (concat
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1700 "\\`\\("
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1701 (make-string (nth 0 reftex-abbrev-parameters) ?.)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1702 "[" (nth 2 reftex-abbrev-parameters) "]*"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1703 "\\)"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1704 "[" (nth 3 reftex-abbrev-parameters) "]"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1705 (make-string (1- (nth 1 reftex-abbrev-parameters)) ?.)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1706
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1707 ;; Global variables used for communication between functions.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1708 (defvar reftex-default-context-position nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1709 (defvar reftex-location-start nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1710 (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
1711 (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
1712 (defvar reftex-active-toc nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1713 (defvar reftex-tex-path nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1714 (defvar reftex-bib-path nil)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
1715 (defvar reftex-last-follow-point nil)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1716 (defvar reftex-prefix)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1717
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1718 ;; List of buffers created temporarily for lookup, which should be killed.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1719 (defvar reftex-buffers-to-kill nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1720
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
1721 ;; Regexp to find section statements. Computed from reftex-section-levels.
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
1722 (defvar reftex-section-regexp nil)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1723 (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
1724 (defvar reftex-everything-regexp nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1725 (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
1726 (defvar reftex-find-label-regexp-format2 nil)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1727
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1728 ;; The parser functions ----------------------------------
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1729
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1730 (defvar reftex-memory nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1731 "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
1732
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1733 (defun reftex-access-scan-info (&optional rescan file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1734 ;; Access the scanning info. When the multifile symbols are not yet tied,
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1735 ;; tie them. When they are empty or RESCAN is non-nil, scan the document.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1736 ;; 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
1737
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1738 ;; Reset the mode if we had changes to important variables.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1739 (when (or reftex-tables-dirty
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1740 (not (eq reftex-label-alist (nth 0 reftex-memory)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1741 (not (eq reftex-label-alist-external-add-ons
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1742 (nth 1 reftex-memory)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1743 (not (eq reftex-default-label-alist-entries
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1744 (nth 2 reftex-memory))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1745 (reftex-reset-mode))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1746
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1747 (if (eq reftex-docstruct-symbol nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1748 ;; 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
1749 (reftex-tie-multifile-symbols))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1750
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1751 (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
1752 (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
1753 ;; 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
1754 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1755 (reftex-erase-all-selection-buffers)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1756
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1757 (if (and (null (symbol-value reftex-docstruct-symbol))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1758 reftex-save-parse-info)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1759 ;; 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
1760 (reftex-access-parse-file 'read))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1761
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1762 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1763 ((not (symbol-value reftex-docstruct-symbol))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1764 (reftex-do-parse 1 file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1765 ((member rescan '(t 1 (4) (16)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1766 (reftex-do-parse rescan file))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1767
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1768 (defun reftex-do-parse (rescan &optional file)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1769 ;; Do a 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
1770
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1771 ;; Normalize the rescan argument
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1772 (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
1773 ((eq rescan 1) 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1774 ((equal rescan '(4)) t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1775 ((equal rescan '(16)) 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1776 (t 1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1777
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1778 ;; Partial scans only when allowed
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1779 (unless reftex-enable-partial-scans
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1780 (setq rescan 1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1781
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1782 ;; Do the scanning.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1783
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1784 (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
1785 (master (reftex-TeX-master-file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1786 (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
1787 (file (or file (buffer-file-name)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1788 from-file appendix docstruct tmp)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1789
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1790 ;; 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
1791 (when (and (eq rescan t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1792 (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
1793 (member (list 'eof file) old-list))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1794 (message "Scanning whole document (no file section %s)" file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1795 (setq rescan 1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1796 (when (string= file master)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1797 (message "Scanning whole document (%s is master)" file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1798 (setq rescan 1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1799
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1800 ;; From which file do we start?
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1801 (setq from-file
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1802 (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
1803 ((eq rescan 1) master)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1804 (t (error "horrible!!"))))
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 ;; 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
1807 (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
1808 '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
1809 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
1810 '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
1811
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1812 (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
1813
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1814 (if (eq rescan 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1815 (message "Scanning entire document...")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1816 (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
1817
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1818 (save-window-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1819 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1820 (unwind-protect
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1821 (setq docstruct
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1822 (reftex-parse-from-file
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1823 from-file docstruct master-dir))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1824 (reftex-kill-temporary-buffers))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1825
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1826 (message "Scanning document... done")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1827
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1828 ;; Turn the list around.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1829 (setq docstruct (nreverse docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1830
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1831 ;; Set or insert
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1832 (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
1833 old-list docstruct (eq rescan 1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1834
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1835 ;; Add all missing information
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1836 (unless (assq 'label-numbers docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1837 (push (cons 'label-numbers nil) docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1838 (unless (assq 'master-dir docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1839 (push (cons 'master-dir master-dir) docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1840 (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
1841 (bof2 (assq 'bof (cdr bof1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1842 (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
1843 (entry (or (assq 'is-multi docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1844 (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
1845 (setcdr entry (cons is-multi nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1846 (unless (assq 'xr docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1847 (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
1848 (alist (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1849 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1850 (lambda (x)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1851 (if (setq tmp (reftex-find-tex-file (nth 2 x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1852 master-dir))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1853 (cons (nth 1 x) tmp)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1854 (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
1855 (nth 2 x))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1856 nil)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1857 allxr))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1858 (alist (delete nil alist))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1859 (allprefix (delete nil (mapcar 'car alist)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1860 (regexp (if allprefix
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1861 (concat "\\`\\("
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1862 (mapconcat 'identity allprefix "\\|")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1863 "\\)")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1864 "\\\\\\\\\\\\"))) ; this will never match
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1865 (push (list 'xr alist regexp) docstruct)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1866
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1867 (set reftex-docstruct-symbol docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1868
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1869 ;; Save the parsing information into a file?
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1870 (if reftex-save-parse-info
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1871 (reftex-access-parse-file 'write))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1872
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1873 (defun reftex-is-multi ()
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1874 ;; Tell if this is a multifile document. When not sure, say yes.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1875 (let ((entry (assq 'is-multi (symbol-value reftex-docstruct-symbol))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1876 (if entry
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1877 (nth 1 entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1878 t)))
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 (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
1881 ;; 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
1882 (let ((regexp reftex-everything-regexp)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1883 (bound 0)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1884 file-found tmp include-file
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1885 (level 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1886 (highest-level 100)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1887 toc-entry next-buf)
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 (catch 'exit
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1890 (setq file-found (reftex-find-tex-file file master-dir))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1891 (unless file-found
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1892 (push (list 'file-error file) docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1893 (throw 'exit nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1894
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1895 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1896
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1897 (message "Scanning file %s" file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1898 (set-buffer
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1899 (setq next-buf
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1900 (reftex-get-file-buffer-force
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1901 file-found
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1902 (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
1903
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1904 ;; Begin of file mark
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1905 (setq file (buffer-file-name))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1906 (push (list 'bof file) docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1907
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1908 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1909 (save-restriction
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1910 (widen)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1911 (goto-char 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1912
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1913 (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
1914
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1915 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1916
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1917 ((match-end 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1918 ;; It is a label
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1919 (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
1920 docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1921
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1922 ((match-end 3)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1923 ;; It is a section
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1924 (setq bound (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1925
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1926 ;; Insert in List
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1927 (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
1928 (setq level (nth 5 toc-entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1929 (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
1930 (if (= level highest-level)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1931 (message
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1932 "Scanning %s %s ..."
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1933 (car (nth level reftex-section-levels))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1934 (nth 6 toc-entry)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1935
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1936 (push toc-entry docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1937 (setq reftex-active-toc toc-entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1938
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1939 ((match-end 7)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1940 ;; 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
1941 (setq include-file (reftex-match-string 7))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1942 (if (delq nil (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1943 (lambda (x) (string-match x include-file))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1944 reftex-no-include-regexps))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1945 (progn
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1946 ;; Ignore the file
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1947 (push (list 'bof include-file) docstruct)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1948 (push (list 'eof include-file) docstruct))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1949 ;; Parse it
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1950 (setq docstruct
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1951 (reftex-parse-from-file
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1952 include-file
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1953 docstruct master-dir))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1954
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1955 ((match-end 9)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1956 ;; Appendix starts here
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1957 (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
1958 (push (cons 'appendix t) docstruct))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1959
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1960 ((match-end 10)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1961 ;; A macro with label
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1962 (save-excursion
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1963 (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
1964 (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
1965 (save-match-data
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1966 (reftex-no-props
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1967 (reftex-nth-arg-wrapper
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1968 mac)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1969 (entry (progn (goto-char (match-end 0))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1970 (reftex-label-info
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1971 label file bound mac))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1972 (push entry docstruct))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1973 (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
1974 )
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1975
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1976
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1977 ;; Find bibliography statement
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1978 (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
1979 (push (cons 'bib tmp) docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1980
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1981 (goto-char 1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1982 (when (re-search-forward
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1983 "\\(\\`\\|[\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
1984 (push (cons 'thebib file) docstruct))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1985
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1986 ;; Find external document specifications
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1987 (goto-char 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1988 (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
1989 (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
1990 (reftex-match-string 3))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1991 docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1992
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1993 ;; End of file mark
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1994 (push (list 'eof file) docstruct))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1995
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1996 ;; Kill the scanned buffer
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1997 (reftex-kill-temporary-buffers next-buf))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1998
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1999 ;; Return the list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2000 docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2001
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2002 (defun reftex-locate-bibliography-files (master-dir)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2003 ;; Scan buffer for bibliography macro and return file list.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2004 (let (file-list)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2005 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2006 (goto-char (point-min))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2007 (if (re-search-forward
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2008 "\\(\\`\\|[\n\r]\\)[ \t]*\\\\bibliography{[ \t]*\\([^}]+\\)" nil t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2009 (setq file-list
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2010 (mapcar (function (lambda (x) (concat x ".bib")))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2011 (reftex-delete-list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2012 reftex-bibfile-ignore-list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2013 (split-string
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2014 (reftex-match-string 2)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2015 "[ \t\n\r]*,[ \t\n\r]*")))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2016 (delete nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2017 (mapcar
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2018 (function
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2019 (lambda (file)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2020 (reftex-find-bib-file file master-dir)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2021 file-list)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2022
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2023 (defun reftex-last-assoc-before-elt (key elt list)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2024 ;; Find the last association of KEY in LIST before or at ELT
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2025 ;; ELT is found in LIST with equal, not eq.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2026 ;; Returns nil when either KEY or elt are not found in LIST.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2027 ;; On success, returns the association.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2028 (let* ((elt (car (member elt list))) ass last-ass)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2029
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2030 (while (and (setq ass (assoc key list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2031 (setq list (memq ass list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2032 (memq elt list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2033 (setq last-ass ass
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2034 list (cdr list)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2035 last-ass))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2036
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2037 (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
2038 ;; 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
2039 ;; 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
2040 ;; 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
2041 ;; 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
2042
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2043 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2044 (entirely
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2045 (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
2046 insert)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2047 (t (let* ((new old)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2048 (file (nth 1 (car insert)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2049 (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
2050 (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
2051 n)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2052 (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
2053 (error "Cannot splice")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2054 ;; Splice
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2055 (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
2056 (length eof-list)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2057 (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
2058 (setcdr (nthcdr n new) (cdr insert))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2059 (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
2060 new))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2061
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2062 (defun reftex-silence-toc-markers (list n)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2063 ;; Set all markers in list to nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2064 (while (and list (> (decf n) -1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2065 (and (eq (car (car list)) 'toc)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2066 (markerp (nth 4 (car list)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2067 (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
2068 (pop list)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2069
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2070 (defun reftex-access-parse-file (action)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2071 (let* ((list (symbol-value reftex-docstruct-symbol))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2072 (master (reftex-TeX-master-file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2073 (enable-local-variables nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2074 (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
2075 (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
2076 (concat master ".rel"))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2077 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2078 ((eq action 'readable)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2079 (file-readable-p file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2080 ((eq action 'restore)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2081 (if (eq reftex-docstruct-symbol nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2082 ;; 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
2083 (reftex-tie-multifile-symbols))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2084 (if (file-exists-p file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2085 ;; load the file and return t for success
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2086 (progn (load-file file) t)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2087 ;; throw an exception
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2088 (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
2089 ((eq action 'read)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2090 (if (file-exists-p file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2091 ;; load the file and return t for success
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2092 (progn (load-file file) t)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2093 ;; 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
2094 nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2095 (t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2096 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2097 (if (file-writable-p file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2098 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2099 (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
2100 (find-file file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2101 (erase-buffer)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2102 (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
2103 (insert (format ";; File: %s\n" master))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2104 (insert (format ";; Date: %s\n"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2105 (format-time-string "%D %T"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2106 (current-time))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2107 (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
2108 (user-login-name) (user-full-name)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2109 (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
2110 (let ((standard-output (current-buffer)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2111 (mapcar
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2112 (function
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2113 (lambda (x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2114 (cond ((eq (car x) 'toc)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2115 ;; 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
2116 ;; 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
2117 (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
2118 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
2119 (or (and (markerp (nth 4 x))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2120 (marker-position (nth 4 x)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2121 (nth 8 x)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2122 (t (print x)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2123 list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2124 (insert "))")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2125 (save-buffer 0)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2126 (kill-buffer (current-buffer)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2127 (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
2128 t))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2129
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2130 ;; Creating labels --------------
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2131
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2132 (defun reftex-label (&optional environment no-insert)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
2133 "Insert a unique label. Return the label.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2134 If ENVIRONMENT is given, don't bother to find out yourself.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2135 If NO-INSERT is non-nil, do not insert label into buffer.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2136 With prefix arg, force to rescan document first.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2137 When you are prompted to enter or confirm a label, and you reply with
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2138 just the prefix or an empty string, no label at all will be inserted.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2139 A new label is also recorded into the label list.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2140 This function is controlled by the settings of reftex-insert-label-flags."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2141
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2142 (interactive)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2143
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
2144 ;; Ensure access to scanning info and rescan buffer if prefix are is '(4).
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2145 (reftex-access-scan-info current-prefix-arg)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2146
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
2147 ;; Find out what kind of environment this is and abort if necessary.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2148 (if (or (not environment)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2149 (not (assoc environment reftex-env-or-mac-alist)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2150 (setq environment (reftex-label-location)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2151 (unless environment
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2152 (error "Can't figure out what kind of label should be inserted"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2153
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
2154 ;; Ok, go ahead.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2155 (catch 'exit
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2156 (let* ((entry (assoc environment reftex-env-or-mac-alist))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2157 (typekey (nth 1 entry))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2158 (format (nth 3 entry))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2159 label prefix valid default force-prompt rescan-is-useful)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2160 (when (and (eq (string-to-char environment) ?\\)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2161 (nth 5 entry)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2162 (memq (preceding-char) '(?\[ ?\{)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2163 (setq format "%s"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2164
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2165 (setq prefix (or (cdr (assoc typekey reftex-typekey-to-prefix-alist))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2166 (concat typekey "-")))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2167 ;; Replace any escapes in the prefix
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2168 (setq prefix (reftex-replace-prefix-escapes prefix))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2169
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2170 ;; Make a default label.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2171 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2172
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2173 ((reftex-typekey-check typekey (nth 0 reftex-insert-label-flags))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2174 ;; Derive a label from context.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2175 (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
2176 'toc (car (reftex-where-am-I))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2177 (symbol-value reftex-docstruct-symbol)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2178 (setq default (reftex-no-props
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2179 (nth 2 (reftex-label-info " " nil nil t))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2180 ;; Catch the cases where the is actually no context available.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2181 (if (or (string-match "NO MATCH FOR CONTEXT REGEXP" default)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2182 (string-match "ILLEGAL VALUE OF PARSE" default)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2183 (string-match "SECTION HEADING NOT FOUND" default)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2184 (string-match "HOOK ERROR" default)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2185 (string-match "^[ \t]*$" default))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2186 (setq default prefix
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2187 force-prompt t) ; need to prompt
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2188 (setq default (concat prefix (reftex-string-to-label default)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2189
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2190 ;; Make it unique.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2191 (setq default (reftex-uniquify-label default nil "-"))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2192
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2193 ((reftex-typekey-check typekey (nth 1 reftex-insert-label-flags))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2194 ;; Minimal default: the user will be prompted.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2195 (setq default prefix))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2196
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2197 (t
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2198 ;; Make an automatic label.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2199 (setq default (reftex-uniquify-label prefix t))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2200
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2201 ;; Should we ask the user?
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2202 (if (or (reftex-typekey-check typekey
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2203 (nth 1 reftex-insert-label-flags)) ; prompt
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2204 force-prompt)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2205
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2206 (while (not valid)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2207 ;; iterate until we get a legal label
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2208
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2209 (setq label (read-string
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2210 (if (string= format "%s") "Naked Label: " "Label: ")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2211 default))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2212
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2213 ;; Lets make sure that this is a legal label
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2214 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2215
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2216 ((string-match (concat "\\`\\(" (regexp-quote prefix)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2217 "\\)?[ \t]*\\'")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2218 label)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2219 ;; No label at all, please
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2220 (message "No label inserted.")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2221 (throw 'exit nil))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2222
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2223 ;; Test if label contains strange characters
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2224 ((string-match reftex-label-illegal-re label)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2225 (message "Label \"%s\" contains illegal characters" label)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2226 (ding)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2227 (sit-for 2))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2228
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2229 ;; Look it up in the label list
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2230 ((setq entry (assoc label
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2231 (symbol-value reftex-docstruct-symbol)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2232 (ding)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2233 (if (y-or-n-p
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2234 (format "Label '%s' exists. Use anyway? " label))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2235 (setq valid t)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2236
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2237 ;; Label is ok
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2238 (t
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2239 (setq valid t))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2240 (setq label default))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2241
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2242 ;; Insert the label into the label list
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2243 (let* ((here-I-am-info (reftex-where-am-I))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2244 (here-I-am (car here-I-am-info))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2245 (note (if (cdr here-I-am-info)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2246 ""
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2247 "POSITION UNCERTAIN. RESCAN TO FIX."))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2248 (file (buffer-file-name))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2249 (text nil)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2250 (tail (memq here-I-am (symbol-value reftex-docstruct-symbol))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2251
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2252 (or (cdr here-I-am-info) (setq rescan-is-useful t))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2253
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2254 (if tail
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2255 (setcdr tail (cons (list label typekey text file note)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2256 (cdr tail)))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2257
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2258 ;; Insert the label into the buffer
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2259 (unless no-insert
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2260 (insert
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2261 (if reftex-format-label-function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2262 (funcall reftex-format-label-function label format)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2263 (format format label))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2264
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2265 ;; Delete the corresponding selection buffers to force update on next use.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2266 (when reftex-auto-update-selection-buffers
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2267 (reftex-erase-buffer (reftex-make-selection-buffer-name typekey))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2268 (reftex-erase-buffer (reftex-make-selection-buffer-name " ")))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2269
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2270 (when (and rescan-is-useful reftex-allow-automatic-rescan)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2271 (reftex-parse-one))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2272
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2273 ;; return value of the function is the label
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2274 label)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2275
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2276 (defun reftex-string-to-label (string)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2277 ;; Convert a string (a sentence) to a label.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2278 ;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2279 ;; Uses reftex-derive-label-parameters and reftex-abbrev-parameters
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2280 ;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2281
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2282 (let* ((words0 (split-string string "[- \t\n\r]+"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2283 (ignore-words (nth 5 reftex-derive-label-parameters))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2284 words word)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2285
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2286 ;; remove words from the ignore list or with funny characters
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2287 (while (setq word (pop words0))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2288 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2289 ((member (downcase word) ignore-words))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2290 ((string-match reftex-label-illegal-re word)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2291 (when (nth 2 reftex-derive-label-parameters)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2292 (while (string-match reftex-label-illegal-re word)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2293 (setq word (replace-match "" nil nil word)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2294 (push word words)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2295 (t
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2296 (push word words))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2297 (setq words (nreverse words))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2298
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2299 ;; restrict number of words
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2300 (if (> (length words) (nth 0 reftex-derive-label-parameters))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2301 (setcdr (nthcdr (1- (nth 0 reftex-derive-label-parameters)) words) nil))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2302
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2303 ;; First, try to use all words
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2304 (setq string (mapconcat 'identity words
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2305 (nth 4 reftex-derive-label-parameters)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2306
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2307 ;; Abbreviate words if enforced by user settings or string length
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2308 (if (or (eq t (nth 3 reftex-derive-label-parameters))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2309 (and (nth 3 reftex-derive-label-parameters)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2310 (> (length string) (nth 1 reftex-derive-label-parameters))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2311 (setq words
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2312 (mapcar
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2313 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2314 (lambda (w) (if (string-match reftex-abbrev-regexp w)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2315 (match-string 1 w)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2316 w)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2317 words)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2318 string (mapconcat 'identity words
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2319 (nth 4 reftex-derive-label-parameters))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2320
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2321 ;; Shorten if still to long
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2322 (setq string
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2323 (if (> (length string) (nth 1 reftex-derive-label-parameters))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2324 (substring string 0 (nth 1 reftex-derive-label-parameters))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2325 string))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2326
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2327 ;; Delete the final punctuation, if any
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2328 (if (string-match "[^a-zA-Z0-9]+\\'" string)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2329 (setq string (replace-match "" nil nil string)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2330 string))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2331
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2332 (defun reftex-replace-prefix-escapes (prefix)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2333 ;; Replace %escapes in a label prefix
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2334 (save-match-data
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2335 (let (letter (num 0) replace)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2336 (while (string-match "\\%\\([a-zA-Z]\\)" prefix num)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2337 (setq letter (match-string 1 prefix))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2338 (setq replace
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2339 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2340 ((equal letter "f")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2341 (file-name-sans-extension
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2342 (file-name-nondirectory (buffer-file-name))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2343 ((equal letter "F")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2344 (let ((masterdir (file-name-directory (reftex-TeX-master-file)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2345 (file (file-name-sans-extension (buffer-file-name))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2346 (if (string-match (concat "\\`" (regexp-quote masterdir))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2347 file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2348 (substring file (length masterdir))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2349 file)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2350 ((equal letter "u")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2351 (or (user-login-name) ""))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2352 (t "")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2353 (setq num (1- (+ (match-beginning 1) (length replace)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2354 prefix (replace-match replace nil nil prefix)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2355 prefix)))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2356
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2357 (defun reftex-label-location (&optional bound)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2358 ;; Return the environment or macro which determines the label type at point.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2359 ;; If optional BOUND is an integer, limit backward searches to that point.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2360
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2361 (let* ((loc1 (reftex-what-macro reftex-label-mac-list bound))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2362 (loc2 (reftex-what-environment reftex-label-env-list bound))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2363 (p1 (or (cdr loc1) 0))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2364 (p2 (or (cdr loc2) 0)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2365
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2366 (setq reftex-location-start (max p1 p2))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2367 (if (>= p1 p2)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2368 (progn
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2369 (setq reftex-default-context-position (+ p1 (length (car loc1))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2370 (or (car loc1) "section"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2371 (setq reftex-default-context-position (+ p2 8 (length (car loc2))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2372 (or (car loc2) "section"))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2373
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2374 (defun reftex-uniquify-label (label &optional force separator)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2375 ;; Make label unique by appending a number.
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2376 ;; Optional FORCE means, force appending a number, even if label is unique.
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2377 ;; Optional SEPARATOR is a string to stick between label and number.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2378
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2379 ;; Ensure access to scanning info
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2380 (reftex-access-scan-info)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2381
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2382 (cond
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2383 ((and (not force)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2384 (not (assoc label (symbol-value reftex-docstruct-symbol))))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2385 label)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2386 (t
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2387 (let* ((label-numbers (assq 'label-numbers
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2388 (symbol-value reftex-docstruct-symbol)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2389 (label-numbers-alist (cdr label-numbers))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2390 (cell (or (assoc label label-numbers-alist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2391 (car (setcdr label-numbers
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2392 (cons (cons label 0)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2393 label-numbers-alist)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2394 (num (1+ (cdr cell)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2395 (sep (or separator "")))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2396 (while (assoc (concat label sep (int-to-string num))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2397 (symbol-value reftex-docstruct-symbol))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2398 (incf num))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2399 (setcdr cell num)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2400 (concat label sep (int-to-string num))))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2401
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2402 ;; Help string for the reference label menu
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2403 (defconst reftex-select-label-prompt
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2404 "Select: [n]ext [p]revious [r]escan [ ]context e[x]tern [q]uit RET [?]HELP+more")
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2405
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2406 (defconst reftex-select-label-help
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2407 " n / p Go to next/previous label (Cursor motion works as well)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2408 C-c C-n/p Go to next/previous section heading.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2409 b / l Jump back to previous selection / Reuse last referenced label
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2410 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
2411 g / s Update menu / Switch label type
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2412 r / R Reparse document / Reparse entire document
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2413 x Switch to label menu of external document (with LaTeX package `xr')
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2414 t i c # % Toggle: [i]ncl. file borders, [t]able of contents, [c]ontext
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2415 [#] label counters, [%] labels in comments
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2416 SPC / f Show full context in other window / Toggle follow mode
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2417 v / . Toggle \\ref <-> \\vref / Show insertion point in other window
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2418 TAB Enter a label with completion
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2419 q / RET Quit without referencing / Accept current label (also on mouse-2)")
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2420
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2421 (defvar reftex-select-label-map nil
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2422 "Keymap used for *RefTeX Select* buffer, when selecting a label.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2423 This keymap can be used to configure the label selection process which is
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2424 started with the command \\[reftex-reference].")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2425
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2426 (defun reftex-select-label-mode ()
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2427 "Major mode for selecting a label in a LaTeX document.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2428 This buffer was created with RefTeX.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2429 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
2430 selection process.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2431 To select a label, 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
2432 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
2433
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2434 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
2435
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2436 \\{reftex-select-label-map}"
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2437
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2438 (interactive)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2439 (kill-all-local-variables)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2440 (make-local-hook 'pre-command-hook)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2441 (make-local-hook 'post-command-hook)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2442 (setq major-mode 'reftex-select-label-mode
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2443 mode-name "RefTeX Select Label")
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2444 ;; 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
2445 (run-hooks 'reftex-select-label-mode-hook))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2446
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2447 (defun reftex-reference (&optional type no-insert cut)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
2448 "Make a LaTeX reference. Look only for labels of a certain TYPE.
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
2449 With prefix arg, force to rescan buffer for labels. This should only be
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2450 necessary if you have recently entered labels yourself without using
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
2451 reftex-label. Rescanning of the buffer can also be requested from the
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2452 label selection menu.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2453 The function returns the selected label or nil.
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
2454 If NO-INSERT is non-nil, do not insert \\ref command, just return label.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2455 When called with 2 C-u prefix args, disable magic word recognition."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2456
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2457 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2458
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2459 ;; check for active recursive edits
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2460 (reftex-check-recursive-edit)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2461
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2462 ;; 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
2463 (reftex-access-scan-info current-prefix-arg)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2464
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2465 (unless type
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2466 ;; guess type from context
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2467 (if (and reftex-guess-label-type
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2468 (setq type (reftex-guess-label-type)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2469 (setq cut (cdr type)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2470 type (car type))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2471 (setq type (reftex-query-label-type))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2472
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2473 (let* ((varioref (if (reftex-typekey-check
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2474 type reftex-vref-is-default)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2475 "\\vref" "\\ref"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2476 (form "\\ref{%s}")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2477 label pair)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2478
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2479 ;; Have the user select a label
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2480 (set-marker reftex-select-return-marker (point))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2481 (setq pair (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2482 (reftex-offer-label-menu type)))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2483 (set-marker reftex-select-return-marker nil)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2484 (setq label (car pair)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2485 type (cdr pair)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2486 form (or (cdr (assoc type reftex-typekey-to-format-alist))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2487 form))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2488
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2489 (if (and label
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2490 (not no-insert))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2491 (progn
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2492 (if cut (backward-delete-char cut))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2493
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2494 ;; remove ~ if we do already have a space
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2495 (when (and (= ?~ (string-to-char form))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2496 (= ?\ (preceding-char)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2497 (setq form (substring form 1)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2498 ;; do we need to switch from \ref to \vref?
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2499 (when (string= varioref "\\vref")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2500 (while (string-match "\\\\ref{" form)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2501 (setq form (replace-match "\\vref{" t t form))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2502 ;; ok, insert the reference
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2503 (insert
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2504 (if reftex-format-ref-function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2505 (funcall reftex-format-ref-function label form)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2506 (format form label label)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2507 (message ""))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2508 (message "Quit"))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2509 ;; return the label
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2510 label))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2511
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2512 (defun reftex-guess-label-type ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2513 (let ((words reftex-words-to-typekey-alist)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2514 (case-fold-search t)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2515 (bound (max (point-min) (- (point) 35)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2516 matched cell)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2517 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2518 (while (and (setq cell (pop words))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2519 (not (setq matched
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2520 (re-search-backward (car cell) bound t))))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2521 (if matched
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2522 (cons (cdr cell) (- (match-end 0) (match-end 1)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2523 nil)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2524
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2525 (defun reftex-offer-label-menu (typekey)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2526 ;; Offer a menu with the appropriate labels. Return (label . typekey).
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2527 (let* ((buf (current-buffer))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2528 (xr-data (assq 'xr (symbol-value reftex-docstruct-symbol)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2529 (xr-alist (cons (cons "" (buffer-file-name)) (nth 1 xr-data)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2530 (xr-index 0)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2531 (here-I-am (car (reftex-where-am-I)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2532 (here-I-am1 here-I-am)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2533 (toc (reftex-typekey-check typekey reftex-label-menu-flags 0))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2534 (files (reftex-typekey-check typekey reftex-label-menu-flags 7))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2535 (context (not (reftex-typekey-check
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2536 typekey reftex-label-menu-flags 3)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2537 (counter (reftex-typekey-check
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2538 typekey reftex-label-menu-flags 2))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2539 (follow (reftex-typekey-check
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2540 typekey reftex-label-menu-flags 4))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2541 (commented (nth 5 reftex-label-menu-flags))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2542 (prefix "")
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2543 selection-buffers
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2544 offset rtn key data last-data entry)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2545
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2546 (setq entry (cons nil nil))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2547
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2548 ;; The following unwind-protect kills temporary buffers after use
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2549 (unwind-protect
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2550 (catch 'exit
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2551 (while t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2552 (save-window-excursion
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2553 (delete-other-windows)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2554 (setq reftex-call-back-to-this-buffer buf)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2555 (let ((default-major-mode 'reftex-select-label-mode))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2556 (if reftex-use-multiple-selection-buffers
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2557 (switch-to-buffer-other-window
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2558 (save-excursion
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2559 (set-buffer buf)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2560 (reftex-make-selection-buffer-name typekey)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2561 (switch-to-buffer-other-window "*RefTeX Select*")
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2562 (reftex-erase-buffer)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2563 (unless (eq major-mode 'reftex-select-label-mode)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2564 (reftex-select-label-mode))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2565 (add-to-list 'selection-buffers (current-buffer))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2566 (setq truncate-lines t)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2567 (setq mode-line-format
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2568 (list "---- " 'mode-line-buffer-identification
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2569 " " 'varioref
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2570 " " (abbreviate-file-name
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2571 (buffer-file-name buf))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2572 " -%-"))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2573 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2574 ((= 0 (buffer-size))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2575 (let ((buffer-read-only nil))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2576 (setq offset (reftex-make-and-insert-label-list
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2577 typekey buf toc files context counter commented
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2578 (or here-I-am offset) prefix))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2579 (here-I-am
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2580 (setq offset (reftex-get-offset buf here-I-am typekey)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2581 (t (setq offset t)))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2582 (setq buffer-read-only t)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2583 (setq offset (or offset t))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2584
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2585 (setq here-I-am nil) ; turn off determination of offset
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2586 (setq rtn
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2587 (reftex-select-item
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2588 reftex-select-label-prompt
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2589 reftex-select-label-help
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2590 reftex-select-label-map
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2591 offset
21115
fea2f6a2818d 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21114
diff changeset
2592 'reftex-select-label-callback follow))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2593 (setq key (car rtn)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2594 data (nth 1 rtn)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2595 last-data (nth 2 rtn)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2596 offset t)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2597 (unless key (throw 'exit nil))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2598 (cond
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2599 ((eq key ?g)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2600 ;; update buffer
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2601 (reftex-erase-buffer))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2602 ((or (eq key ?r)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2603 (eq key ?R))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2604 ;; rescan buffer
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2605 (reftex-erase-buffer)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2606 (reftex-parse-document buf last-data key))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2607 ((eq key ?c)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2608 ;; toggle context mode
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2609 (reftex-erase-buffer)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2610 (setq context (not context)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2611 ((eq key ?s)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2612 ;; switch type
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2613 (setq here-I-am here-I-am1)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2614 (setq typekey (reftex-query-label-type)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2615 ((eq key ?t)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2616 ;; toggle table of contents display
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2617 (reftex-erase-buffer)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2618 (setq toc (not toc)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2619 ((eq key ?i)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2620 ;; toggle display of included file borders
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2621 (reftex-erase-buffer)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2622 (setq files (not files)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2623 ((eq key ?#)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2624 ;; toggle counter display
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2625 (reftex-erase-buffer)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2626 (setq counter (not counter)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2627 ((eq key ?%)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2628 ;; toggle display of commented labels
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2629 (reftex-erase-buffer)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2630 (setq commented (not commented)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2631 ((eq key ?l)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2632 ;; reuse the last referenced label again
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2633 (setq entry reftex-last-used-reference)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2634 (throw 'exit t))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2635 ((eq key ?x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2636 ;; select an external document
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2637 (setq xr-index (reftex-select-external-document
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2638 xr-alist xr-index))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2639 (setq buf (or (reftex-get-file-buffer-force
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
2640 (cdr (nth xr-index xr-alist)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2641 (error "Cannot switch document"))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2642 prefix (or (car (nth xr-index xr-alist)) ""))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2643 (set-buffer buf)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2644 (reftex-access-scan-info))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2645 ((stringp key)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2646 (setq entry
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2647 (or (assoc key (symbol-value reftex-docstruct-symbol))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2648 (list key typekey)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2649 (throw 'exit t))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2650 (t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2651 (set-buffer buf)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2652 (if data
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2653 (progn
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2654 (setq entry data)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2655 (setq reftex-last-used-reference entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2656 (setq entry nil))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2657 (throw 'exit t))))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2658 (mapcar (function (lambda (buf)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2659 (and (buffer-live-p buf)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2660 (bury-buffer buf))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2661 selection-buffers)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2662 (reftex-kill-buffer "*RefTeX Context Copy*")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2663 (reftex-kill-temporary-buffers))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2664 (cons (if (nth 0 entry) (concat prefix (nth 0 entry)) nil)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2665 (nth 1 entry))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2666
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2667 (defun reftex-select-external-document (xr-alist xr-index)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2668 ;; Return index of an external document.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2669 (let* ((len (length xr-alist)) (highest (1- (+ ?0 len)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2670 (prompt (format "[%c-%c] Select SPC/DEL: Scroll TAB: Read prefix with completion" ?0 highest))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2671 key prefix)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2672 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2673 ((= len 1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2674 (message "No external documents available")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2675 (ding) 0)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2676 ((= len 2)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2677 (- 1 xr-index))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2678 (t
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2679 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2680 (save-window-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2681 (let* ((length (apply 'max (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2682 (lambda(x) (length (car x))) xr-alist)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2683 (fmt (format " [%%c] %%-%ds %%s\n" length))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2684 (n (1- ?0)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2685 (with-output-to-temp-buffer "*RefTeX Select*"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2686 (princ "SELECT EXTERNAL DOCUMENT\n------------------------\n")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2687 (princ
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2688 (mapconcat
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2689 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2690 (lambda (x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2691 (format fmt (incf n) (or (car x) "")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2692 (abbreviate-file-name (cdr x)))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2693 xr-alist ""))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2694 (reftex-enlarge-to-fit "*RefTeX Select*")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2695 (select-window (get-buffer-window "*RefTeX Select*"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2696 (setq truncate-lines t)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2697 (catch 'exit
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2698 (while t
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2699 (princ prompt)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2700 (setq key (read-char-exclusive))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2701 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2702 ((= key ?\C-?) (condition-case nil (scroll-down) (error nil)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2703 ((= key ?\ ) (condition-case nil (scroll-up) (error nil)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2704 ((and (>= key ?0) (<= key highest))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2705 (throw 'exit (- key ?0)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2706 ((= key ?\C-i)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2707 (setq prefix (completing-read "Prefix: " xr-alist nil t))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2708 (throw 'exit (- len (length (memq (assoc prefix xr-alist)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2709 xr-alist)))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2710 (t (error "Illegal document selection [%c]" key)))))))))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2711
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2712 (defun reftex-make-selection-buffer-name (type &optional index)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2713 ;; Make unique name for a selection buffer.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2714 (format "*RefTeX[%s][%d]*"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2715 type (or index (get reftex-docstruct-symbol ':master-index) 0)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2716
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2717 (defun reftex-get-offset (buf here-am-I typekey)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2718 ;; Find the correct offset data, like make-and-insert would, but faster.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2719 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2720 (set-buffer buf)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2721 (reftex-access-scan-info)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2722 (let* ((rest (memq here-am-I (symbol-value reftex-docstruct-symbol)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2723 entry)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2724 (while (and (setq entry (pop rest))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2725 (not (and (stringp (car entry))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2726 (equal typekey (nth 1 entry))))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2727 entry)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2728
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2729 (defun reftex-make-and-insert-label-list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2730 (typekey0 buf toc files context counter show-commented here-I-am xr-prefix)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2731 ;; Insert a menu of all labels in buffer BUF into current buffer.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2732 ;; Return the data property of the entry corresponding to HERE-I-AM.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2733 (let* ((font (reftex-use-fonts))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2734 (cnt 0)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2735 (index -1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2736 (toc-indent " ")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2737 (label-indent
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2738 (concat "> "
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2739 (if toc (make-string (* 7 reftex-level-indent) ?\ ) "")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2740 (context-indent
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2741 (concat ". "
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2742 (if toc (make-string (* 7 reftex-level-indent) ?\ ) "")))
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
2743 (mouse-face
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
2744 (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
2745 reftex-mouse-selected-face
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
2746 nil))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2747 all cell text label typekey note comment master-dir-re
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2748 offset from to docstruct-symbol)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2749
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2750 (message "Creating Selection Buffer...")
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2751
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2752 ;; Pop to buffer buf to get the correct buffer-local variables
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2753 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2754 (set-buffer buf)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2755
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2756 ;; Ensure access to scanning info
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2757 (reftex-access-scan-info)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2758
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2759 (setq docstruct-symbol reftex-docstruct-symbol
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2760 all (symbol-value reftex-docstruct-symbol)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2761 reftex-active-toc nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2762 master-dir-re
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2763 (concat "\\`" (regexp-quote
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2764 (file-name-directory (reftex-TeX-master-file))))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2765
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2766 (set (make-local-variable 'reftex-docstruct-symbol) docstruct-symbol)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2767 (set (make-local-variable 'reftex-prefix)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2768 (cdr (assoc typekey0 reftex-typekey-to-prefix-alist)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2769 (if (equal reftex-prefix " ") (setq reftex-prefix nil))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2770
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2771 ;; Walk the docstruct and insert the appropriate stuff
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2772 (while (setq cell (pop all))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2773
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2774 (incf index)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2775 (setq from (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2776
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2777 (if (eq cell here-I-am) (setq offset 'attention))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2778
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2779 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2780
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2781 ((memq (car cell) '(bib thebib label-numbers appendix
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2782 master-dir is-multi xr xr-doc)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2783 ;; These are currently ignored
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2784
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2785 ((memq (car cell) '(bof eof file-error))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2786 ;; Beginning or end of a file
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2787 (when files
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2788 (insert
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2789 " File " (if (string-match master-dir-re (nth 1 cell))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2790 (substring (nth 1 cell) (match-end 0))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2791 (nth 1 cell))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2792 (cond ((eq (car cell) 'bof) " starts here\n")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2793 ((eq (car cell) 'eof) " ends here\n")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2794 ((eq (car cell) 'file-error) " was not found\n")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2795 (when font
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2796 (put-text-property from (point)
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
2797 'face reftex-file-boundary-face))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2798
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2799 ((eq (car cell) 'toc)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2800 ;; a table of contents entry
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2801 (when toc
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2802 (setq reftex-active-toc cell)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2803 (insert (concat toc-indent (nth 2 cell) "\n"))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2804
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2805 ((stringp (car cell))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2806 ;; a label
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2807 (when (null (nth 2 cell))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2808 ;; No context yet. Quick update.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2809 (setcdr cell (cdr (reftex-label-info-update cell))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2810
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2811 (setq label (car cell)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2812 typekey (nth 1 cell)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2813 text (nth 2 cell)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2814 note (nth 4 cell)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2815 comment (get-text-property 0 'in-comment text))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2816
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2817 (when (and (or (string= typekey typekey0) (string= typekey0 " "))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2818 (or show-commented (null comment)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2819
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2820 ;; Yes we want this one
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2821 (incf cnt)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2822 (if (eq offset 'attention) (setq offset cell))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2823
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2824 (setq label (concat xr-prefix label))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2825 (when comment (setq label (concat "% " label)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2826 (insert label-indent label)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2827 (when font
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2828 (put-text-property
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2829 (- (point) (length label)) (point)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2830 'face (if comment
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2831 'font-lock-comment-face
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
2832 reftex-label-face)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2833
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2834 (insert (if counter (format " (%d) " cnt) "")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2835 (if comment " LABEL IS COMMENTED OUT " "")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2836 (if note (concat " " note) "")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2837 "\n")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2838 (setq to (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2839
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2840 (when context
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2841 (insert context-indent text "\n")
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2842 (setq to (point)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2843 (put-text-property from to ':data cell)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2844 (when mouse-face
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2845 (put-text-property from (1- to)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2846 'mouse-face mouse-face))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2847 (goto-char to)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2848
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2849 (when (reftex-refontify)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2850 (reftex-fontify-select-label-buffer))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2851 offset))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2852
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2853 (defun reftex-parse-document (&optional buffer data key)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2854 "Rescan the document."
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2855 (interactive)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2856 (save-window-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2857 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2858 (if buffer
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2859 (if (not (bufferp buffer))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2860 (error "No such buffer %s" (buffer-name buffer))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2861 (set-buffer buffer)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2862 (let ((arg (if (eq key ?R) '(16) '(4)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2863 (file (nth 3 data)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2864 (reftex-access-scan-info arg file)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2865
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2866 (defun reftex-query-label-type ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2867 ;; Ask for label type
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2868 (message reftex-type-query-prompt)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2869 (let ((key (read-char)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2870 (when (eq key ?\?)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2871 (save-window-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2872 (with-output-to-temp-buffer "*RefTeX Help*"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2873 (princ reftex-type-query-help))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2874 (reftex-enlarge-to-fit "*RefTeX Help*")
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2875 (setq key (read-char))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2876 (kill-buffer "*RefTeX Help*")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2877 (unless (member (char-to-string key) reftex-typekey-list)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2878 (error "No such label type: %s" (char-to-string key)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2879 (char-to-string key)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2880
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2881 ;; Variable holding the vector with section numbers
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2882 (defvar reftex-section-numbers [0 0 0 0 0 0 0 0])
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2883
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2884 (defun reftex-section-info (file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2885 ;; 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
2886 ;; 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
2887 (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
2888 (macro (reftex-match-string 3))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2889 (star (= ?* (char-after (match-end 3))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2890 (level (cdr (assoc macro reftex-section-levels)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2891 (section-number (reftex-section-number level star))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2892 (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
2893 (literal (buffer-substring-no-properties
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2894 (1- (match-beginning 3))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2895 (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
2896 ;; 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
2897 (text (reftex-nicify-text text1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2898
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2899 ;; Add section number and indentation
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2900 (setq text
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2901 (concat
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2902 (make-string (* reftex-level-indent level) ?\ )
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2903 (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
2904 (concat section-number " "))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2905 text))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2906 ;; Fontify
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2907 (if (reftex-use-fonts)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2908 (put-text-property 0 (length text)
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
2909 'face reftex-section-heading-face text))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2910 (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
2911 literal (marker-position marker))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2912
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2913 (defun reftex-label-info-update (cell)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2914 ;; Update information about just one label in a different file.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2915 ;; CELL contains the old info list
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2916 (let* ((label (nth 0 cell))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2917 (typekey (nth 1 cell))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2918 ;; (text (nth 2 cell))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2919 (file (nth 3 cell))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2920 (note (nth 4 cell))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2921 (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
2922 file (not (eq t reftex-keep-temporary-buffers)))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2923 (if (not buf)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
2924 (list label typekey "" file "LOST LABEL. RESCAN TO FIX.")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2925 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2926 (set-buffer buf)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2927 (save-restriction
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2928 (widen)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2929 (goto-char 1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2930
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2931 (if (or (re-search-forward
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2932 (format reftex-find-label-regexp-format
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2933 (regexp-quote label)) nil t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2934 (re-search-forward
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2935 (format reftex-find-label-regexp-format2
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2936 (regexp-quote label)) nil t))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2937
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2938 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2939 (backward-char 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2940 (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
2941 (list label typekey "" file "LOST LABEL. RESCAN TO FIX.")))))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2942
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2943 (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
2944 ;; 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
2945 (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
2946 (typekey (nth 1 (assoc env-or-mac reftex-env-or-mac-alist)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2947 (file (or file (buffer-file-name)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2948 (parse (if (reftex-typekey-check
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2949 typekey reftex-use-text-after-label-as-context)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2950 nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2951 (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
2952 (text (reftex-short-context env-or-mac parse reftex-location-start
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2953 derive)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2954 (if (reftex-in-comment)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2955 (put-text-property 0 1 'in-comment t text))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2956 (list label typekey text file)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2957
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2958 (defun reftex-in-comment ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2959 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2960 (skip-chars-backward "^%\n\r")
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2961 (eq (preceding-char) ?%)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2962
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2963 (defun reftex-short-context (env parse &optional bound derive)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2964 ;; 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
2965
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2966 (if (consp parse)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2967 (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
2968
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2969 (reftex-nicify-text
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2970
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2971 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2972
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2973 ((null parse)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2974 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2975 (reftex-context-substring)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2976
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2977 ((eq parse t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2978 (if (string= env "section")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2979 ;; special treatment for section labels
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2980 (save-excursion
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2981 (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
2982 (point-min) t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2983 (match-end 2))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2984 (progn
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2985 (goto-char (match-end 0))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2986 (reftex-context-substring))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2987 (if reftex-active-toc
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2988 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2989 (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
2990 (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
2991 "SECTION HEADING NOT FOUND")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2992 (save-excursion
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2993 (goto-char reftex-default-context-position)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2994 (unless (eq (string-to-char env) ?\\)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2995 (reftex-move-over-touching-args))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2996 (reftex-context-substring))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2997
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2998 ((stringp parse)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2999 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3000 (if (re-search-backward parse bound t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3001 (progn
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3002 (goto-char (match-end 0))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3003 (reftex-context-substring))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3004 "NO MATCH FOR CONTEXT REGEXP")))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3005
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3006 ((integerp parse)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3007 (or (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3008 (goto-char reftex-default-context-position)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3009 (reftex-nth-arg
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3010 parse
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3011 (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
3012 ""))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3013
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3014 ((fboundp parse)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
3015 ;; A hook function. Call it.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3016 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3017 (condition-case error-var
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3018 (funcall parse env)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3019 (error (format "HOOK ERROR: %s" (cdr error-var))))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3020 (t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3021 "ILLEGAL VALUE OF PARSE"))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3022
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3023 (defun reftex-where-am-I ()
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3024 ;; 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
3025 ;; 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
3026 ;; exact (t) or approximate (nil).
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3027
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3028 (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
3029 (cnt 0) rtn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3030 found)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3031 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3032 (while (not rtn)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3033 (incf cnt)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3034 (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
3035 (setq rtn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3036 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3037 ((not found)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3038 ;; no match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3039 (or
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3040 (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
3041 (not (setq cnt 2))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3042 (assq 'bof docstruct) ;; for safety reasons
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3043 'corrupted))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3044 ((match-end 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3045 ;; Label
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3046 (assoc (reftex-match-string 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3047 (symbol-value reftex-docstruct-symbol)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3048 ((match-end 3)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3049 ;; Section
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3050 (goto-char (1- (match-beginning 3)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3051 (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
3052 docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3053 (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
3054 list)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3055 rtn1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3056 (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
3057 (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
3058 (string= (buffer-file-name)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3059 (nth 3 (car list))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3060 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3061 ((equal (point)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3062 (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
3063 (marker-position (nth 4 (car list))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3064 (nth 8 (car list))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3065 ;; 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
3066 (setq rtn1 (car list) list nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3067 ((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
3068 (nth 7 (car list))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3069 ;; Same title
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3070 (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
3071 (pop list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3072 rtn1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3073 ((match-end 7)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3074 ;; Input or include...
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3075 (car
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3076 (member (list 'eof (reftex-find-tex-file
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3077 (reftex-match-string 7)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3078 (cdr (assq 'master-dir docstruct))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3079 docstruct)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3080 ((match-end 9)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3081 (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
3082 ((match-end 10)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3083 (save-excursion
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3084 (goto-char (match-end 10))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3085 (assoc (reftex-no-props
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3086 (reftex-nth-arg-wrapper
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3087 (reftex-match-string 10)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3088 (symbol-value reftex-docstruct-symbol))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3089 (t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3090 (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
3091 (cons rtn (eq cnt 1))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3092
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3093 (defun reftex-parse-args (macro)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3094 ;; 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
3095 ;; optional argument indices.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3096 (if (string-match "[[{]\\*?[]}]" macro)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3097 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3098 (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
3099 (args (substring macro (match-beginning 0)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3100 opt-list nlabel (cnt 0))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3101 (while (string-match "\\`[[{]\\(\\*\\)?[]}]" args)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3102 (incf cnt)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3103 (when (eq ?\[ (string-to-char args))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3104 (push cnt opt-list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3105 (when (and (match-end 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3106 (not nlabel))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3107 (setq nlabel cnt))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3108 (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
3109 (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
3110 nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3111
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3112 (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
3113 ;; 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
3114 ;; 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
3115 ;; 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
3116 ;; in TeX.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3117 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3118 ;; Just to be quick:
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3119 ((memq (following-char) '(?\[ ?\{)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3120 ;; Do a search
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3121 ((looking-at "[ \t]*[\n\r]?\\([ \t]*%[^\n\r]*[\n\r]\\)*[ \t]*[[{]")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3122 (goto-char (1- (match-end 0)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3123 t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3124 (t nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3125
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3126 (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
3127 ;; 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
3128 ;; 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
3129 ;; 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
3130 ;; in TeX.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3131 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3132 ;; Just to be quick:
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3133 ((memq (preceding-char) '(?\] ?\})))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3134 ;; Do a search
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3135 ((re-search-backward
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3136 "[]}][ \t]*[\n\r]?\\([ \t]*%[^\n\r]*[\n\r]\\)*[ \t]*\\=" bound t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3137 (goto-char (1+ (match-beginning 0)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3138 t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3139 (t nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3140
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3141 (defun reftex-nth-arg-wrapper (key)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3142 (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
3143 (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
3144
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3145 (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
3146 ;; 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
3147 ;; 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
3148
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3149 ;; 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
3150 (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
3151
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3152 (if (= n 1000)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3153 ;; Special case: Skip all touching arguments
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3154 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3155 (reftex-move-over-touching-args)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3156 (reftex-context-substring))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3157
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3158 ;; Do the real thing.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3159 (let ((cnt 1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3160
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3161 (when (reftex-move-to-next-arg)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3162
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3163 (while (< cnt n)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3164 (while (and (member cnt opt-args)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3165 (eq (following-char) ?\{))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3166 (incf cnt))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3167 (when (< cnt n)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3168 (unless (and (condition-case nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3169 (or (forward-list 1) t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3170 (error nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3171 (reftex-move-to-next-arg)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3172 (incf cnt))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3173 (setq cnt 1000))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3174
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3175 (while (and (memq cnt opt-args)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3176 (eq (following-char) ?\{))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3177 (incf cnt)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3178 (if (and (= n cnt)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3179 (> (skip-chars-forward "{\\[") 0))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3180 (reftex-context-substring)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3181 nil))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3182
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3183 (defun reftex-move-over-touching-args ()
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3184 (condition-case nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3185 (while (memq (following-char) '(?\[ ?\{))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3186 (forward-list 1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3187 (error nil)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3188
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3189 (defun reftex-context-substring ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3190 ;; Return up to 100 chars from point
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3191 ;; When point is just after a { or [, limit string to matching parenthesis
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3192 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3193 ((or (= (preceding-char) ?\{)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3194 (= (preceding-char) ?\[))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3195 ;; 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
3196 (buffer-substring-no-properties
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3197 (point)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3198 (min (reftex-fp 150)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3199 (point-max)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3200 (condition-case nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3201 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3202 (up-list 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3203 (1- (point)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3204 (error (point-max))))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3205 (t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3206 ;; no list - just grab 100 characters
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3207 (buffer-substring-no-properties (point) (min (reftex-fp 150) (point-max))))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3208
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3209 (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
3210 ;; 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
3211 ;; in the toc entry.
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3212 (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
3213 (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
3214 (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
3215 (i depth) number-string)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3216 (while (>= i 0)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3217 (if (> i level)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3218 (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
3219 (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
3220 (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
3221 (aset reftex-section-numbers i
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3222 (- (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
3223 (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
3224 (pop numbers))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3225 (decf i)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3226 (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
3227
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3228 (defun reftex-section-number (&optional level star)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3229 ;; Return a string with the current section number.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3230 ;; 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
3231 (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
3232 (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
3233 (when level
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3234 (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
3235 (aset reftex-section-numbers
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3236 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
3237 (setq idx (1+ level))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3238 (while (<= idx depth)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3239 (aset reftex-section-numbers idx 0)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3240 (incf idx)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3241 (setq idx 0)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3242 (while (<= idx depth)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3243 (setq n (aref reftex-section-numbers idx))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3244 (setq string (concat string (if (not (string= string "")) "." "")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3245 (int-to-string n)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3246 (incf idx))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3247 (save-match-data
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3248 (if (string-match "\\`\\([@0]\\.\\)+" string)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3249 (setq string (replace-match "" nil nil string)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3250 (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
3251 (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
3252 (if (and appendix
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3253 (string-match "\\`[0-9]+" string))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3254 (setq string (concat (char-to-string (1- (+ ?A (string-to-int (match-string 0 string))))) (substring string (match-end 0))))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3255
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3256 (if star
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3257 (concat (make-string (1- (length string)) ?\ ) "*")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3258 string)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3259
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3260 (defun reftex-select-label-callback (data forward no-revisit)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3261 ;; Callback function called from the label selection in order to
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3262 ;; show context in another window
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3263 (let* ((this-window (selected-window))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3264 label file buffer re found)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3265 ;; pop to original buffer in order to get correct variables
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3266 (catch 'exit
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3267 (setq label (nth 0 data)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3268 file (nth 3 data))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3269
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3270 ;; 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
3271 (setq buffer
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3272 (if no-revisit
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3273 (get-file-buffer file)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3274 (reftex-get-file-buffer-force
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3275 file (not reftex-keep-temporary-buffers))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3276 (if buffer
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3277 ;; good - the file is available
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3278 (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
3279 ;; we have got a problem here. The file does not exist.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3280 ;; Let' get out of here..
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3281 ;; (ding)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3282 (throw 'exit nil))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3283
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3284 ;; search for that label
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3285 (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
3286 (setq found
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3287 (if forward
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3288 (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
3289 (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
3290 (unless found
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3291 (goto-char (point-min))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3292 (unless (re-search-forward re nil t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3293 ;; Ooops. Must be in a macro with distributed args.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3294 (re-search-forward (format reftex-find-label-regexp-format2
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3295 (regexp-quote label)) nil t)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3296 (when (match-end 3)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3297 (reftex-highlight 0 (match-beginning 3) (match-end 3))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3298 (reftex-show-entry (- (point) (match-beginning 3))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3299 (- (point) (match-end 3)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3300 (recenter (/ (window-height) 2)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3301 (select-window this-window))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3302
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3303 (defun reftex-pop-to-label (label file-list &optional mark-to-kill highlight)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3304 ;; Find LABEL in any file in FILE-LIST in another window.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3305 ;; If mark-to-kill is non-nil, mark new buffer for killing.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3306 ;; If HIGHLIGHT is non-nil, highlight the label definition.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3307 (let* ((re1 (format reftex-find-label-regexp-format (regexp-quote label)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3308 (re2 (format reftex-find-label-regexp-format2 (regexp-quote label)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3309 (re-list (list re1 re2)) re
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3310 (file-list-1 file-list)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3311 file buf)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3312 (catch 'exit
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3313 (while (setq re (pop re-list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3314 (setq file-list file-list-1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3315 (while (setq file (pop file-list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3316 (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
3317 (error "No such file %s" file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3318 (set-buffer buf)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3319 (widen)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3320 (goto-char (point-min))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3321 (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
3322 (switch-to-buffer-other-window buf)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3323 (goto-char (match-beginning 0))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3324 (recenter (/ (window-height) 2))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3325 (if highlight
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3326 (reftex-highlight 0 (match-beginning 3) (match-end 3)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3327 (throw 'exit (selected-window)))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3328 (error "Label %s not found" label))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3329
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3330 (defun reftex-find-duplicate-labels ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3331 "Produce a list of all duplicate labels in the document."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3332
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3333 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3334
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3335 ;; Rescan the document to make sure
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3336 (reftex-access-scan-info t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3337
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3338 (let ((master (reftex-TeX-master-file))
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
3339 (cnt 0)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3340 (dlist
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3341 (mapcar
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3342 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3343 (lambda (x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3344 (let (x1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3345 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3346 ((memq (car x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3347 '(toc bof eof bib thebib label-numbers xr xr-doc
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3348 master-dir file-error appendix is-multi))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3349 nil)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3350 (t
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3351 (setq x1 (reftex-all-assoc-string
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3352 (car x) (symbol-value reftex-docstruct-symbol)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3353 (if (< 1 (length x1))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3354 (append (list (car x))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3355 (mapcar (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3356 (lambda(x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3357 (abbreviate-file-name (nth 3 x))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3358 x1))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3359 (list nil)))))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3360 (reftex-uniquify (symbol-value reftex-docstruct-symbol)))))
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
3361
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3362 (setq dlist (reftex-uniquify dlist))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3363 (if (null dlist) (error "No duplicate labels in document"))
18219
aaeaae005e98 Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents: 18123
diff changeset
3364 (switch-to-buffer-other-window "*Duplicate Labels*")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3365 (make-local-variable 'TeX-master)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3366 (setq TeX-master master)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3367 (erase-buffer)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3368 (insert " MULTIPLE LABELS IN CURRENT DOCUMENT:\n")
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
3369 (insert
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
3370 " Move point to label and type `r' to run a query-replace on the label\n"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
3371 " and its references. Type `q' to exit this buffer.\n\n")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3372 (insert " LABEL FILE\n")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3373 (insert " -------------------------------------------------------------\n")
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
3374 (use-local-map (make-sparse-keymap))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3375 (local-set-key [?q] (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3376 (lambda () (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3377 (kill-buffer (current-buffer)) (delete-window))))
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
3378 (local-set-key [?r] 'reftex-change-label)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3379 (while dlist
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3380 (when (and (car (car dlist))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3381 (cdr (car dlist)))
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
3382 (incf cnt)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3383 (insert (mapconcat 'identity (car dlist) "\n ") "\n"))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3384 (pop dlist))
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
3385 (goto-char (point-min))
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
3386 (when (= cnt 0)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
3387 (kill-buffer (current-buffer))
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
3388 (delete-window)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
3389 (message "Document does not contain duplicate labels."))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3390
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3391 (defun reftex-all-assq (key list)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3392 ;; Return a list of all associations of KEY in LIST. Comparison with string=
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3393 (let (rtn)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3394 (while (setq list (memq (assq key list) list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3395 (push (car list) rtn)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3396 (pop list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3397 (nreverse rtn)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3398
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3399 (defun reftex-all-assoc-string (key list)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
3400 ;; Return a list of all associations of KEY in LIST. Comparison with string=
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3401 (let (rtn)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3402 (while list
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3403 (if (string= (car (car list)) key)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3404 (push (car list) rtn))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3405 (pop list))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3406 (nreverse rtn)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3407
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3408 (defun reftex-kill-temporary-buffers (&optional buffer)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3409 ;; Kill all buffers in the list reftex-kill-temporary-buffers.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3410 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3411 (buffer
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3412 (when (member buffer reftex-buffers-to-kill)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3413 (kill-buffer buffer)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3414 (setq reftex-buffers-to-kill
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3415 (delete buffer reftex-buffers-to-kill))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3416 (t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3417 (while (setq buffer (pop reftex-buffers-to-kill))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3418 (when (bufferp buffer)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3419 (and (buffer-modified-p buffer)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3420 (y-or-n-p (format "Save file %s? "
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3421 (buffer-file-name buffer)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3422 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3423 (set-buffer buffer)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3424 (save-buffer)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3425 (kill-buffer buffer))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3426 (pop reftex-buffers-to-kill)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3427
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3428 (defun reftex-show-entry (beg-hlt end-hlt)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3429 ;; Show entry if point is hidden by outline mode
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3430 (let* ((pos (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3431 (n (/ (window-height) 2))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3432 (beg (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3433 (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
3434 (end (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3435 (re-search-forward "[\n\r]" nil 1 n) (point))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3436 (if (and reftex-auto-show-entry
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3437 (string-match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3438 "\r" (buffer-substring beg end)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3439 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3440 ((eq t reftex-auto-show-entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3441 (subst-char-in-region
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3442 (save-excursion (search-backward "\n" nil t) (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3443 (save-excursion (search-forward "\n" nil t) (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3444 ?\r ?\n t))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3445 ((eq reftex-auto-show-entry 'copy)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3446 (let ((string (buffer-substring beg end)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3447 (switch-to-buffer "*RefTeX Context Copy*")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3448 (setq buffer-read-only nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3449 (erase-buffer)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3450 (insert string)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3451 (subst-char-in-region (point-min) (point-max) ?\r ?\n t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3452 (goto-char (- pos beg))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3453 (reftex-highlight 0 (1+ (- (point) beg-hlt))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3454 (1+ (- (point) end-hlt)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3455 (when (reftex-refontify)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3456 (set (make-local-variable 'font-lock-defaults) nil)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3457 (let ((major-mode 'latex-mode))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3458 (font-lock-mode 1)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3459 (setq buffer-read-only t)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3460 ))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3461
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3462 (defun reftex-nicify-text (text)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3463 ;; Make TEXT nice for inclusion as context into label menu
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3464 ;; remove line breaks and extra white space
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3465 (while (string-match "[\n\r\t]\\|[ \t][ \t]+" text)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3466 (setq text (replace-match " " nil t text)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3467 ;; cut before the next `\end{' or `\item' or `\\'
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3468 (if (string-match "\\(\\\\end{\\|\\\\item\\|\\\\\\\\\\).*" text)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3469 (setq text (replace-match "" nil t text)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3470 ;; kill the embedded label
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3471 (if (string-match "\\\\label{[^}]*}" text)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3472 (setq text (replace-match "" nil t text)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3473 ;; remove leading garbage
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3474 (if (string-match "\\`[ }]+" text)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3475 (setq text (replace-match "" nil t text)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3476 ;; limit length
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3477 (cond
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3478 ((> (length text) 100) (substring text 0 100))
21124
2089d9bfb3d7 (reftex-nicify-text): make a new " " string each time.
Carsten Dominik <dominik@science.uva.nl>
parents: 21115
diff changeset
3479 ((= (length text) 0) (make-string 1 ?\ ))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3480 (t text)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3481
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3482 (defun reftex-typekey-check (typekey conf-variable &optional n)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3483 ;; Check if CONF-VARIABLE is true or contains TYPEKEY
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3484 (and n (setq conf-variable (nth n conf-variable)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3485 (or (eq conf-variable t)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3486 (and (stringp conf-variable)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3487 (string-match (concat "[" conf-variable "]") typekey))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3488
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3489 ;;; ===========================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3490 ;;;
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3491 ;;; Table of contents
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3492
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3493 ;; 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
3494
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3495 (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
3496 "Keymap used for *toc* buffer.")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3497
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3498 (defun reftex-toc-mode ()
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3499 "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
3500 This buffer was created with RefTeX.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3501 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
3502
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3503 Here are all local bindings.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3504
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3505 \\{reftex-toc-map}"
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3506 (interactive)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3507 (kill-all-local-variables)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3508 (setq major-mode 'reftex-toc-mode
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3509 mode-name "RefTeX Table of Contents")
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3510 (use-local-map reftex-toc-map)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3511 (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
3512 (setq truncate-lines t)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3513 (make-local-hook 'post-command-hook)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3514 (make-local-hook 'pre-command-hook)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3515 (make-local-variable 'reftex-last-follow-point)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3516 (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
3517 (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
3518 (run-hooks 'reftex-toc-mode-hook))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3519
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3520 (defvar reftex-last-toc-master nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3521 "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
3522
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3523 (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
3524 "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
3525
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3526 (defvar reftex-last-window-height nil)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3527
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3528 (defvar reftex-toc-return-marker (make-marker)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3529 "Marker which makes it possible to return from toc to old position.")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3530
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3531 (defconst reftex-toc-help
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3532 " AVAILABLE KEYS IN TOC BUFFER
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3533 ============================
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3534 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
3535 SPC Show the corresponding section of the LaTeX document.
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3536 TAB Goto the section.
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3537 RET Goto the section and hide the *toc* buffer (also on mouse-2).
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3538 q / Q Hide/Kill *toc* buffer, return to position of last reftex-toc command.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3539 f / g Toggle follow mode on and off / Refresh *toc* buffer.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3540 r / R Reparse the LaTeX document / Reparse entire LaTeX document.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3541 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
3542
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3543 (defun reftex-toc ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3544 "Show the table of contents for the current document.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3545 When called with a raw C-u prefix, rescan the document first."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3546
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3547 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3548
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3549 (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
3550 current-prefix-arg)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3551 (reftex-erase-buffer "*toc*"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3552
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3553 (setq reftex-last-toc-file (buffer-file-name))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3554 (setq reftex-last-toc-master (reftex-TeX-master-file))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3555
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3556 (set-marker reftex-toc-return-marker (point))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3557
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3558 ;; If follow mode is active, arrange to delay it one command
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3559 (if reftex-toc-follow-mode
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3560 (setq reftex-toc-follow-mode 1))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3561
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3562 ;; 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
3563 (reftex-access-scan-info current-prefix-arg)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3564
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3565 (let* ((all (symbol-value reftex-docstruct-symbol))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3566 (xr-data (assq 'xr all))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3567 (xr-alist (cons (cons "" (buffer-file-name)) (nth 1 xr-data)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3568 (where (reftex-nearest-section))
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
3569 (mouse-face
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
3570 (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
3571 reftex-mouse-selected-face
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
3572 nil))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3573 toc1 cell startpos)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3574
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3575 (if (get-buffer-window "*toc*")
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3576 (select-window (get-buffer-window "*toc*"))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3577 (when (< (window-height) (* 2 window-min-height))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3578 (delete-other-windows))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3579 (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
3580 (split-window)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3581 (let ((default-major-mode 'reftex-toc-mode))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3582 (switch-to-buffer "*toc*")))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3583
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3584 (or (eq major-mode 'reftex-toc-mode) (reftex-toc-mode))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3585
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3586 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3587 ;; buffer is empty - fill it with the table of contents
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3588 ((= (buffer-size) 0)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3589 (message "Building *toc* buffer...")
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3590
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3591 (setq buffer-read-only nil)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3592 (insert (format
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3593 "TABLE-OF-CONTENTS on %s
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3594 SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [f]ollow-mode e[x]tern [?]Help
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3595 -------------------------------------------------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3596 " (abbreviate-file-name reftex-last-toc-master)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3597 (setq startpos (point))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3598
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3599 (if (reftex-use-fonts)
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
3600 (put-text-property 1 (point) 'face reftex-toc-header-face))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3601 (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
3602 (put-text-property 1 2 'xr-alist xr-alist)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3603
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3604 (while all
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3605 (setq cell (car all)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3606 all (cdr all))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3607 (when (eq (car cell) 'toc)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3608 (setq toc1 (concat (nth 2 cell) "\n"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3609 (put-text-property 0 (length toc1) 'toc cell toc1)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3610 (when mouse-face
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3611 (put-text-property 0 (1- (length toc1))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3612 'mouse-face mouse-face toc1))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3613 (insert toc1)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3614
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3615 (backward-delete-char 1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3616
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3617 (message "Building *toc* buffer...done.")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3618 (setq buffer-read-only t))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3619 (t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3620 (goto-line 3)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3621 (beginning-of-line)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3622 (setq startpos (point))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3623
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3624 ;; Find the correct section
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3625 (goto-char (point-max))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3626 (beginning-of-line)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3627 (while (and (> (point) startpos)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3628 (not (eq (get-text-property (point) 'toc) where)))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3629 (beginning-of-line 0))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3630 (setq reftex-last-follow-point (point))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3631
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3632 (defun reftex-nearest-section ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3633 ;; Return (file . find) of nearest section command
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3634 (let* ((here-I-am (car (reftex-where-am-I))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3635 (reftex-last-assoc-before-elt
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3636 'toc here-I-am (symbol-value reftex-docstruct-symbol))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3637
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3638 (defun reftex-toc-pre-command-hook ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3639 ;; used as pre command hook in *toc* buffer
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3640 (reftex-unhighlight 0)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3641 (reftex-unhighlight 1))
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 (defun reftex-toc-post-command-hook ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3644 ;; used in the post-command-hook for the *toc* buffer
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3645 (and (> (point) 1)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3646 (memq reftex-highlight-selection '(cursor both))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3647 (save-excursion
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3648 (reftex-highlight 1
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3649 (progn (beginning-of-line) (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3650 (progn (end-of-line) (point)))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3651 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3652 ((integerp reftex-toc-follow-mode)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3653 ;; remove delayed action
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3654 (setq reftex-toc-follow-mode t))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3655 ((and reftex-toc-follow-mode
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3656 (not (equal reftex-last-follow-point (point))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3657 ;; show context in other window
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3658 (setq reftex-last-follow-point (point))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3659 (condition-case nil
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3660 (reftex-toc-visit-line nil (not reftex-revisit-to-follow))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3661 (error t)))))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3662
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3663 (defun reftex-re-enlarge ()
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3664 (enlarge-window
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3665 (max 0 (- (or reftex-last-window-height (window-height))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3666 (window-height)))))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3667
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3668 (defun reftex-toc-show-help ()
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3669 (interactive)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3670 (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
3671 (princ reftex-toc-help))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3672 ;; 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
3673 (if reftex-toc-follow-mode
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3674 (setq reftex-toc-follow-mode 1)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3675
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3676 (defun reftex-toc-toggle-follow ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3677 "Toggle toc-follow mode.
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
3678 (It is not really a mode, just a flag)."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3679 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3680 (setq reftex-toc-follow-mode (not reftex-toc-follow-mode)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3681 (defun reftex-toc-view-line ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3682 "View document location in other window."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3683 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3684 (reftex-toc-visit-line))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3685 (defun reftex-toc-mouse-view-line (ev)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3686 "View document location in other window."
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3687 (interactive "e")
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3688 (mouse-set-point ev)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3689 (reftex-toc-visit-line))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3690 (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
3691 "Go to document location in other window. Hide the *toc* window."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3692 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3693 (reftex-toc-visit-line 'hide))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3694 (defun reftex-toc-goto-line ()
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3695 "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
3696 (interactive)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3697 (reftex-toc-visit-line t))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3698 (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
3699 "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
3700 (interactive "e")
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3701 (mouse-set-point ev)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3702 (reftex-toc-visit-line 'hide))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3703 (defun reftex-toc-quit ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3704 "Hide the *toc* window and do not move point."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3705 (interactive)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3706 (or (one-window-p) (delete-window))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3707 (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
3708 (reftex-re-enlarge)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3709 (goto-char (or (marker-position reftex-toc-return-marker) (point))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3710 (defun reftex-toc-quit-and-kill ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3711 "Kill the *toc* buffer."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3712 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3713 (kill-buffer "*toc*")
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3714 (or (one-window-p) (delete-window))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3715 (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
3716 (reftex-re-enlarge)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3717 (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
3718 (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
3719 "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
3720 (interactive)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3721 (if reftex-enable-partial-scans
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3722 (let ((file (nth 3 (get-text-property (point) 'toc))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3723 (if (not file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3724 (error "Don't know which file to rescan. Try `R'.")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3725 (switch-to-buffer-other-window
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3726 (reftex-get-file-buffer-force file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3727 (setq current-prefix-arg '(4))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3728 (reftex-toc)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3729 (reftex-toc-Rescan))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3730 (reftex-kill-temporary-buffers))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3731 (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
3732 "Regenerate the *toc* buffer by reparsing the entire document."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3733 (interactive)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3734 (switch-to-buffer-other-window
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3735 (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
3736 (setq current-prefix-arg '(16))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3737 (reftex-toc))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3738 (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
3739 "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
3740 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3741 (switch-to-buffer-other-window
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3742 (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
3743 (reftex-erase-buffer "*toc*")
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3744 (setq current-prefix-arg nil)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3745 (reftex-toc))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3746 (defun reftex-toc-external (&rest ignore)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3747 "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
3748 (interactive)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3749 (let* ((old-buf (current-buffer))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3750 (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
3751 (xr-index (reftex-select-external-document
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3752 xr-alist 0)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3753 (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
3754 (cdr (nth xr-index xr-alist)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3755 (error "Cannot switch document")))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3756 (reftex-toc)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3757 (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
3758 (message "")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3759 (message "Switched document"))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3760
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3761 (defun reftex-toc-visit-line (&optional final no-revisit)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3762 ;; 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
3763 ;; If FINAL is t, stay there
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3764 ;; 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
3765 ;; Otherwise, move cursor back into *toc* window.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3766 ;; 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
3767 ;; 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
3768 ;; have been active.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3769
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3770 (let* ((toc (get-text-property (point) 'toc))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3771 (file (nth 3 toc))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3772 (marker (nth 4 toc))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3773 (level (nth 5 toc))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3774 (literal (nth 7 toc))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3775 (emergency-point (nth 8 toc))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3776 (toc-window (selected-window))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3777 show-window show-buffer match)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3778
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3779 (unless toc (error "Don't know which toc line to visit"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3780
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3781 (setq match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3782 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3783 ((and (markerp marker) (marker-buffer marker))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3784 ;; Buffer is still live and we have the marker. Should be easy.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3785 (switch-to-buffer-other-window (marker-buffer marker))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3786 (goto-char (marker-position marker))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3787 (or (looking-at (regexp-quote literal))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3788 (looking-at (reftex-make-regexp-allow-for-ctrl-m literal))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3789 (looking-at (reftex-make-desperate-section-regexp literal))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3790 (looking-at (concat "\\\\"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3791 (regexp-quote
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3792 (car (rassq level reftex-section-levels)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3793 "[[{]"))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3794 ((or (not no-revisit)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3795 (get-file-buffer file))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3796 ;; Marker is lost. Use the backup method.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3797 (switch-to-buffer-other-window
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3798 (reftex-get-file-buffer-force file nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3799 (goto-char (or emergency-point (point-min)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3800 (or (looking-at (regexp-quote literal))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3801 (let ((pos (point)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3802 (re-search-backward "\\`\\|[\r\n][ \t]*[\r\n]" nil t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3803 (or (reftex-nearest-match (regexp-quote literal) pos)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3804 (reftex-nearest-match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3805 (reftex-make-regexp-allow-for-ctrl-m literal) pos)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3806 (reftex-nearest-match
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3807 (reftex-make-desperate-section-regexp literal) pos)))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3808 ))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3809
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3810 (setq show-window (selected-window)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3811 show-buffer (current-buffer))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3812
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3813 (unless match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3814 (select-window toc-window)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3815 (error "Cannot find line"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3816
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3817 (goto-char (match-beginning 0))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3818 (recenter 1)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3819 (reftex-highlight 0 (match-beginning 0) (match-end 0) (current-buffer))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3820
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3821 (select-window toc-window)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3822
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3823 ;; use the `final' parameter to decide what to do next
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3824 (cond
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3825 ((eq final t)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3826 (reftex-unhighlight 0)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3827 (select-window show-window))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3828 ((eq final 'hide)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3829 (reftex-unhighlight 0)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3830 (or (one-window-p) (delete-window))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3831 (switch-to-buffer show-buffer)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3832 (reftex-re-enlarge))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3833 (t nil))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3834
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3835 ;;; ===========================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3836 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3837 ;;; BibTeX citations.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3838
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3839 ;; Variables and constants
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3840
18219
aaeaae005e98 Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents: 18123
diff changeset
3841 ;; Define variable to silence compiler warnings
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3842 (defvar reftex-cite-format-builtin)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3843
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3844 ;; The history list of regular expressions used for citations
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3845 (defvar reftex-cite-regexp-hist nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3846
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3847 ;; 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
3848 (defconst reftex-citation-prompt
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3849 "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
3850
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3851 (defconst reftex-citation-help
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3852 " 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
3853 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
3854 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
3855 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
3856 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
3857 . Show insertion point.
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3858 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
3859 TAB Enter citation key with completion.
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3860 RET Accept current entry (also on mouse-2)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3861 a Accept all entries.")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3862
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3863 (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
3864 "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
3865 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
3866 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
3867
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3868 (defun reftex-select-bib-mode ()
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3869 "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
3870 This buffer was created with RefTeX.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3871 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
3872 selection process.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3873 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
3874 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
3875
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3876 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
3877
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3878 \\{reftex-select-label-map}"
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3879 (interactive)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3880 (kill-all-local-variables)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3881 (make-local-hook 'pre-command-hook)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3882 (make-local-hook 'post-command-hook)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3883 (setq major-mode 'reftex-select-bib-mode
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3884 mode-name "RefTeX Select Bib")
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3885 ;; 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
3886 (run-hooks 'reftex-select-bib-mode-hook))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3887
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3888 ;; Find bibtex files
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3889
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3890 (defun reftex-get-bibfile-list ()
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3891 ;; 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
3892 ;; 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
3893 ;; 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
3894 ;; 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
3895 ;; Then this function will return the applicable database files.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3896
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3897 ;; Ensure access to scanning info
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3898 (reftex-access-scan-info)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3899 (or
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3900 ;; 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
3901 (cdr (reftex-last-assoc-before-elt
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3902 'bib (list 'eof (buffer-file-name))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3903 (member (list 'bof (buffer-file-name))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3904 (symbol-value reftex-docstruct-symbol))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3905 ;; 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
3906 (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
3907 (symbol-value reftex-docstruct-symbol))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3908 ;; Anywhere in the entire document
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3909 (cdr (assq 'bib (symbol-value reftex-docstruct-symbol)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3910 (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
3911
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3912 (defun reftex-find-tex-file (file master-dir &optional die)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3913 ;; Find FILE in MASTER-DIR or on reftex-tex-path.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3914 ;; FILE may be given without the .tex extension.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3915 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3916 ((file-name-absolute-p file)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3917 (if (file-exists-p file) file nil))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3918 (t
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3919 (reftex-access-search-path "tex")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3920 (let* ((path (cons master-dir reftex-tex-path))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3921 file1)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3922 (setq file1
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3923 (or (reftex-find-file-on-path (concat file ".tex") path)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3924 (reftex-find-file-on-path file path)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3925 (unless file1
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3926 (reftex-access-search-path "tex" t file)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3927 (setq path (cons master-dir reftex-tex-path))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3928 (setq file1
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3929 (or (reftex-find-file-on-path (concat file ".tex") path)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3930 (reftex-find-file-on-path file path))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3931 (cond (file1 file1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3932 (die (error "No such file: %s" file) nil)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3933 (t (message "No such file: %s (ignored)" file) nil))))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3934
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3935 (defun reftex-find-bib-file (file master-dir &optional die)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3936 ;; Find FILE in MASTER-DIR or on reftex-bib-path
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3937 (reftex-access-search-path "bib")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3938 (let ((file1 (reftex-find-file-on-path
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3939 file (cons master-dir reftex-bib-path))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3940 (unless file1
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3941 (reftex-access-search-path "bib" t file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3942 (setq file1 (reftex-find-file-on-path
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3943 file (cons master-dir reftex-bib-path))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3944 (cond (file1 file1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3945 (die (error "No such file: %s" file) nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3946 (t (message "No such file: %s (ignored)" file) nil))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3947
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3948 ;; Find a certain reference in any of the BibTeX files.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3949
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3950 (defun reftex-pop-to-bibtex-entry (key file-list
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3951 &optional mark-to-kill highlight item)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3952 ;; 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
3953 ;; 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
3954 ;; 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
3955 ;; If ITEM in non-nil, search for bibitem instead of database entry.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3956
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3957 (let* ((re
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3958 (if item
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3959 (concat "\\\\bibitem\\(\\[[^]]*\\]\\)?{" (regexp-quote key) "}")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3960 (concat "@[a-zA-Z]+[ \t\n\r]*[{(][ \t\n\r]*" (regexp-quote key))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3961 (window-conf (current-window-configuration))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3962 file buf)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3963
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3964 (catch 'exit
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3965 (switch-to-buffer-other-window (current-buffer))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3966 (while file-list
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3967 (setq file (car file-list)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3968 file-list (cdr file-list))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3969 (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
3970 (error "No such file %s" file))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3971 (switch-to-buffer buf)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3972 (widen)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3973 (goto-char (point-min))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3974 (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
3975 (goto-char (match-beginning 0))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3976 (recenter 0)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3977 (if highlight
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3978 (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
3979 (throw 'exit (selected-window))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3980 (set-window-configuration window-conf)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3981 (if item
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3982 (message "No \\bibitem with citation key %s" key)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3983 (message "No BibTeX entry with citation key %s" key)))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3984
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3985 ;; Parse bibtex buffers
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3986
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3987 (defun reftex-extract-bib-entries (buffers &optional get-word)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3988 ;; Extract bib entries which match regexps from BUFFERS.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3989 ;; BUFFERS is a list of buffers or file names.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3990 ;; Return list with entries."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3991 (let* (re-list first-re rest-re
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3992 (buffer-list (if (listp buffers) buffers (list buffers)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3993 found-list entry buffer1 buffer alist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3994 key-point start-point end-point)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3995
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3996 (setq re-list (split-string
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3997 (read-string "RegExp [ && RegExp...]: "
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3998 nil 'reftex-cite-regexp-hist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3999 "[ \t]*&&[ \t]*"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4000
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4001 (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
4002 rest-re (cdr re-list)) ; the others to narrow down.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4003 (if (string-match "\\`[ \t]*\\'" first-re)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4004 (error "Empty regular expression"))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4005
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4006 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4007 (save-window-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4008
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4009 ;; Walk through all bibtex files
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4010 (while buffer-list
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4011 (setq buffer (car buffer-list)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4012 buffer-list (cdr buffer-list))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4013 (if (and (bufferp buffer)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4014 (buffer-live-p buffer))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4015 (setq buffer1 buffer)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4016 (setq buffer1 (reftex-get-file-buffer-force
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4017 buffer (not reftex-keep-temporary-buffers))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4018 (if (not buffer1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4019 (error "Cannot find BibTeX file %s" buffer)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4020 (message "Scanning bibliography database %s" buffer1))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4021
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4022 (set-buffer buffer1)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4023 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4024 (goto-char (point-min))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4025 (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
4026 (catch 'search-again
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4027 (setq key-point (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4028 (unless (re-search-backward
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4029 "\\(\\`\\|[\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
4030 (throw 'search-again nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4031 (setq start-point (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4032 (goto-char (match-end 0))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4033 (condition-case nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4034 (up-list 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4035 (error (goto-char key-point)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4036 (throw 'search-again nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4037 (setq end-point (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4038
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4039 ;; 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
4040 ;; outside entries
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4041 (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
4042 (string= (downcase (match-string 2)) "comment")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4043 (string= (downcase (match-string 2)) "c")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4044 (< (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
4045 (goto-char key-point)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4046 (throw 'search-again nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4047
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4048 ;; Well, we have got a match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4049 (setq entry (concat
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4050 (buffer-substring start-point (point)) "\n"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4051
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4052 ;; 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
4053 (setq re-list rest-re)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4054 (while re-list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4055 (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
4056 ;; nope - move on
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4057 (throw 'search-again nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4058 (pop re-list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4059
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4060 (setq alist (reftex-parse-bibtex-entry
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4061 nil start-point end-point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4062 (push (cons "&entry" entry) alist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4063
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4064 ;; check for crossref entries
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4065 (if (assoc "crossref" alist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4066 (setq alist
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4067 (append
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4068 alist (reftex-get-crossref-alist alist))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4069
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4070 ;; format the entry
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4071 (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
4072 alist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4073
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4074 ;; add it to the list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4075 (push alist found-list))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4076 (reftex-kill-temporary-buffers))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4077 (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
4078
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4079 ;; Sorting
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4080 (cond
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4081 ((eq 'author reftex-sort-bibtex-matches)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4082 (sort found-list 'reftex-bib-sort-author))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4083 ((eq 'year reftex-sort-bibtex-matches)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4084 (sort found-list 'reftex-bib-sort-year))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4085 ((eq 'reverse-year reftex-sort-bibtex-matches)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4086 (sort found-list 'reftex-bib-sort-year-reverse))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4087 (t found-list))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4088
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4089 (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
4090 (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
4091 (al2 (reftex-get-bib-names "author" e2)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4092 (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
4093 (pop al1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4094 (pop al2))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4095 (if (and (stringp (car al1))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4096 (stringp (car al2)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4097 (string< (car al1) (car al2))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4098 (not (stringp (car al1))))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4099
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4100 (defun reftex-bib-sort-year (e1 e2)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4101 (< (string-to-int (cdr (assoc "year" e1)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4102 (string-to-int (cdr (assoc "year" e2)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4103
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4104 (defun reftex-bib-sort-year-reverse (e1 e2)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4105 (> (string-to-int (or (cdr (assoc "year" e1)) "0"))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4106 (string-to-int (or (cdr (assoc "year" e2)) "0"))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4107
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4108 (defun reftex-get-crossref-alist (entry)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4109 ;; return the alist from a crossref entry
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4110 (let ((crkey (cdr (assoc "crossref" entry)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4111 start)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4112 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4113 (save-restriction
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4114 (widen)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4115 (if (re-search-forward
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4116 (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
4117 "[ \t\n\r]*,") nil t)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4118 (progn
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4119 (setq start (match-beginning 0))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4120 (condition-case nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4121 (up-list 1)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4122 (error nil))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4123 (reftex-parse-bibtex-entry nil start (point)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4124 nil)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4125
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4126 ;; Parse the thebibliography environment
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4127 (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
4128 ;; 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
4129 ;; 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
4130 ;; 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
4131
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4132 (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
4133 (unless file
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4134 (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
4135 (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
4136 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
4137 (unless buf
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4138 (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
4139 (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
4140
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4141 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4142 (set-buffer buf)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4143 (save-restriction
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4144 (widen)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4145 (goto-char (point-min))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4146 (if (re-search-forward
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4147 "\\(\\`\\|[\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
4148 (progn
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4149 (beginning-of-line 2)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4150 (setq start (point))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4151 (if (re-search-forward
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4152 "\\(\\`\\|[\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
4153 (progn
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4154 (beginning-of-line 1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4155 (setq end (point))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4156 (when (and start (point))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4157 (setq entries
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4158 (mapcar 'reftex-parse-bibitem
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4159 (delete ""
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4160 (split-string
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4161 (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
4162 "[ \t\n\r]*\\\\bibitem\\(\\[[^]]*]\\)*")))))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4163 (unless entries
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4164 (error "No bibitems found"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4165
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4166 (setq re-list (split-string
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4167 (read-string "RegExp [ && RegExp...]: "
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4168 nil 'reftex-cite-regexp-hist)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4169 "[ \t]*&&[ \t]*"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4170 (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
4171 (error "Empty regular expression"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4172
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4173 (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
4174 (setq entries
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4175 (delete nil (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4176 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4177 (lambda (x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4178 (if (string-match re (cdr (assoc "&entry" x)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4179 x nil)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4180 entries))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4181
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4182 (setq entries
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4183 (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4184 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4185 (lambda (x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4186 (cons (cons "&formatted" (reftex-format-bibitem x)) x)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4187 entries))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4188
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4189 entries))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4190
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4191 ;; Parse and format individual entries
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4192
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4193 (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
4194 ;; 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
4195 (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
4196 (if (equal "" names)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4197 (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
4198 (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
4199 (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
4200 (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
4201 (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
4202 (while (string-match "^[ \t]+\\|[ \t]+$" names)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4203 (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
4204 (while (string-match "[ \t][ \t]+" names)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4205 (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
4206 (split-string names "\n")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4207
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4208 (defun reftex-parse-bibtex-entry (entry &optional from to)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4209 (let (alist key start field)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4210 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4211 (save-restriction
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4212 (if entry
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4213 (progn
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4214 (switch-to-buffer "*RefTeX-scratch*")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4215 (fundamental-mode)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4216 (erase-buffer)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4217 (insert entry))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4218 (widen)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4219 (narrow-to-region from to))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4220 (goto-char (point-min))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4221
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4222 (if (re-search-forward
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
4223 "@\\(\\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
4224 (setq alist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4225 (list
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4226 (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
4227 (cons "&key" (reftex-match-string 2)))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4228 (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
4229 (setq key (downcase (reftex-match-string 1)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4230 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4231 ((= (following-char) ?{)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4232 (forward-char 1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4233 (setq start (point))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4234 (condition-case nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4235 (up-list 1)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4236 (error nil)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4237 ((= (following-char) ?\")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4238 (forward-char 1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4239 (setq start (point))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4240 (while (and (search-forward "\"" nil t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4241 (= ?\\ (char-after (- (point) 2))))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4242 (t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4243 (setq start (point))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4244 (re-search-forward "[ \t\n\r,}]" nil 1)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4245 (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
4246 ;; remove extra whitespace
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4247 (while (string-match "[\n\t\r]\\|[ \t][ \t]+" field)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4248 (setq field (replace-match " " nil t field)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4249 ;; remove leading garbage
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4250 (if (string-match "^[ \t{]+" field)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4251 (setq field (replace-match "" nil t field)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4252 ;; remove trailing garbage
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4253 (if (string-match "[ \t}]+$" field)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4254 (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
4255 (push (cons key field) alist))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4256 alist))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4257
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4258 (defun reftex-get-bib-field (fieldname entry)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4259 ;; Extract the field FIELDNAME from an ENTRY
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4260 (or (cdr (assoc fieldname entry))
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
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4263 (defun reftex-format-bib-entry (entry)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4264 ;; Format a BibTeX ENTRY so that it is nice to look at
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4265 (let*
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4266 ((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
4267 (authors (mapconcat 'identity auth-list ", "))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4268 (year (reftex-get-bib-field "year" entry))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4269 (title (reftex-get-bib-field "title" entry))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4270 (type (reftex-get-bib-field "&type" entry))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4271 (key (reftex-get-bib-field "&key" entry))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4272 (extra
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4273 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4274 ((equal type "article")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4275 (concat (reftex-get-bib-field "journal" entry) " "
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4276 (reftex-get-bib-field "volume" entry) ", "
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4277 (reftex-get-bib-field "pages" entry)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4278 ((equal type "book")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4279 (concat "book (" (reftex-get-bib-field "publisher" entry) ")"))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4280 ((equal type "phdthesis")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4281 (concat "PhD: " (reftex-get-bib-field "school" entry)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4282 ((equal type "mastersthesis")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4283 (concat "Master: " (reftex-get-bib-field "school" entry)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4284 ((equal type "inbook")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4285 (concat "Chap: " (reftex-get-bib-field "chapter" entry)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4286 ", pp. " (reftex-get-bib-field "pages" entry)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4287 ((or (equal type "conference")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4288 (equal type "incollection")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4289 (equal type "inproceedings"))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4290 (concat "in: " (reftex-get-bib-field "booktitle" entry)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4291 (t ""))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4292 (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
4293 (when (reftex-use-fonts)
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4294 (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
4295 authors)
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4296 (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
4297 year)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4298 (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
4299 title)
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4300 (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
4301 extra))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4302 (concat key "\n " authors " " year " " extra "\n " title "\n\n")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4303
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4304 (defun reftex-parse-bibitem (item)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4305 ;; Parse a \bibitem entry
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4306 (let ((key "") (text ""))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4307 (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
4308 (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
4309 text (match-string 2 item)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4310 ;; 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
4311 (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
4312 (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
4313 (if (string-match "\\`[ \t]+" text)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4314 (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
4315 (list
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4316 (cons "&key" key)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4317 (cons "&text" text)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4318 (cons "&entry" (concat key " " text)))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4319
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4320 (defun reftex-format-bibitem (item)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4321 ;; 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
4322 (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
4323 (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
4324 (lines nil))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4325
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4326 ;; 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
4327 (while (and (> (length text) 70)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4328 (string-match " " (substring text 60)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4329 (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
4330 (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
4331 (push text lines)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4332 (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
4333
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4334 (when (reftex-use-fonts)
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4335 (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
4336 (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
4337
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4338 ;; Make a citation
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4339
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4340 (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
4341 "Make a citation using BibTeX database files.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4342 After asking for a Regular Expression, it scans the buffers with
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4343 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
4344 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
4345 to `reftex-cite-format' and inserted into the buffer.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4346 If NO-INSERT is non-nil, nothing is inserted, only the selected key returned.
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
4347 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
4348 Thus, `aaaa&&bbb' matches entries which contain both `aaaa' and `bbb'.
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
4349 When this function is called with point inside the braces of a \\cite
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
4350 command, it will add another key, ignoring the value of `reftex-cite-format'.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4351 When called with a numeric prefix, that many citations will be made and all
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
4352 put into the same \\cite command.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4353 When called with just C-u as prefix, enforces rescan of buffer for
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4354 bibliography statement (e.g. if it was changed)."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4355
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4356 (interactive)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4357
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4358 ;; check for recursive edit
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4359 (reftex-check-recursive-edit)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4360
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4361 ;; if there is just 1 C-u prefix arg, force to rescan buffer
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4362 (reftex-access-scan-info current-prefix-arg)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4363
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4364 ;; Call reftex-do-citation, but protected
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4365 (unwind-protect
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4366 (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
4367 (reftex-kill-temporary-buffers)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4368
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4369 (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
4370 ;; 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
4371
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4372 ;; 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
4373 ;; in order to only add another reference in the same cite command.
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4374 (let (key format (macro (car (car (reftex-what-macro t)))))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4375 (if (and (stringp macro)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4376 (string-match "\\`\\\\cite\\|cite\\'" macro))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4377 (progn
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4378 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4379 ((or (not arg)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4380 (not (listp arg)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4381 (setq format
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4382 (concat
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4383 (if (not (or (= (preceding-char) ?{)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4384 (= (preceding-char) ?,)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4385 ","
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4386 "")
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4387 "%l"
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4388 (if (not (or (= (following-char) ?})
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4389 (= (following-char) ?,)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4390 ","
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4391 ""))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4392 (t
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4393 (setq format "%l"))))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4394 ;; else: figure out the correct format
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4395 (setq format
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4396 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4397 ((stringp reftex-cite-format) reftex-cite-format)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4398 ((and (symbolp reftex-cite-format)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4399 (assq reftex-cite-format reftex-cite-format-builtin))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4400 (nth 2 (assq reftex-cite-format reftex-cite-format-builtin)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4401 (t reftex-cite-format)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4402 (if (listp format)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4403 (save-window-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4404 (with-output-to-temp-buffer "*RefTeX Select*"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4405 (princ "SELECT A CITATION FORMAT\n\n")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4406 (princ
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4407 (mapconcat
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4408 (function (lambda (x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4409 (format "[%c] %s %s" (car x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4410 (if (> (car x) 31) " " "")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4411 (cdr x))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4412 format "\n")))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4413 (reftex-enlarge-to-fit "*RefTeX Select*")
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4414 (setq key (read-char))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4415 (if (assq key format)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4416 (setq format (cdr (assq key format)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4417 (error "No citation format associated with key `%c'" key)))))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4418
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4419 (let* (entry data rtn ins-string re-list re found-list found-list-r)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4420
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4421 ;; Scan bibtex files
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4422 (setq found-list
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4423 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4424 ((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
4425 ;; using BibTeX database files.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4426 (reftex-extract-bib-entries (reftex-get-bibfile-list)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4427 ((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
4428 ;; using thebibliography environment.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4429 (reftex-extract-bib-entries-from-thebibliography
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4430 (cdr (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
4431 (reftex-default-bibliography
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4432 (message "Using default bibliography")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4433 (reftex-extract-bib-entries reftex-default-bibliography))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4434 (t (error "Document does not have a bibliography"))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4435
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4436 (unless found-list
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4437 (error "Sorry, no matches found"))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4438
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4439 ;; remember where we came from
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4440 (setq reftex-call-back-to-this-buffer (current-buffer))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4441 (set-marker reftex-select-return-marker (point))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4442
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4443 ;; offer selection
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4444 (save-window-excursion
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4445 (delete-other-windows)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4446 (let ((default-major-mode 'reftex-select-bib-mode))
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4447 (reftex-kill-buffer "*RefTeX Select*")
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4448 (switch-to-buffer-other-window "*RefTeX Select*")
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4449 (unless (eq major-mode 'reftex-select-bib-mode)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4450 (reftex-select-bib-mode))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4451 (let ((buffer-read-only nil))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4452 (erase-buffer)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4453 (reftex-insert-bib-matches found-list)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4454 (setq buffer-read-only t)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4455 (if (= 0 (buffer-size))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4456 (error "Sorry, no matches found"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4457 (setq truncate-lines t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4458 (goto-char 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4459 (if (catch 'exit
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4460 (while t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4461 (setq rtn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4462 (reftex-select-item
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4463 reftex-citation-prompt
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4464 reftex-citation-help
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4465 reftex-select-bib-map
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4466 nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4467 'reftex-bibtex-selection-callback nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4468 (setq key (car rtn)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4469 data (nth 1 rtn))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4470 (unless key (throw 'exit nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4471 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4472 ((eq key ?g)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4473 (setq found-list
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4474 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4475 (set-buffer reftex-call-back-to-this-buffer)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4476 (reftex-extract-bib-entries
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4477 (reftex-get-bibfile-list))))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4478 (let ((buffer-read-only nil))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4479 (erase-buffer)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4480 (reftex-insert-bib-matches found-list))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4481 (if (= 0 (buffer-size))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4482 (error "Sorry, no matches found"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4483 (goto-char 1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4484
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4485 ((eq key ?r)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4486 ;; restrict with new regular expression
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4487 (setq re-list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4488 (split-string (read-string
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4489 "RegExp [ && RegExp...]: "
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4490 nil 'reftex-cite-regexp-hist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4491 "[ \t]*&&[ \t]*"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4492 (while re-list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4493 (setq re (car re-list)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4494 re-list (cdr re-list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4495 (setq found-list-r
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4496 (delete ""
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4497 (mapcar
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4498 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4499 (lambda (x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4500 (if (string-match
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4501 re (cdr (assoc "&entry" x)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4502 x
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4503 "")))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4504 found-list))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4505 (if found-list-r
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4506 (setq found-list found-list-r)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4507 (ding))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4508 (let ((buffer-read-only nil))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4509 (erase-buffer)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4510 (reftex-insert-bib-matches found-list))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4511 (goto-char 1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4512 ((eq key ?a)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4513 (setq entry 'all)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4514 (throw 'exit t))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4515 ((or (eq key ?\C-m)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4516 (eq key 'return))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4517 (if data
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4518 (setq entry data)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4519 (setq entry nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4520 (throw 'exit t))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4521 ((stringp key)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4522 (setq entry (list (cons "&key" key)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4523 (throw 'exit t))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4524 (t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4525 (ding)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4526 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4527 ;; format the entry
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4528 (if (eq entry 'all)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4529 (setq ins-string
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4530 (mapconcat
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4531 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4532 (lambda (entry)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4533 (if reftex-format-cite-function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4534 (funcall reftex-format-cite-function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4535 (reftex-get-bib-field "&key" entry)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4536 format)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4537 (reftex-format-citation entry format))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4538 found-list "\n"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4539 (setq ins-string
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4540 (if reftex-format-cite-function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4541 (funcall reftex-format-cite-function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4542 (reftex-get-bib-field "&key" entry)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4543 format)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4544 (reftex-format-citation entry format)))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4545 (setq ins-string "")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4546 (message "Quit")))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4547 (set-marker reftex-select-return-marker (point))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4548 (kill-buffer "*RefTeX Select*")
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4549
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4550 (unless no-insert
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4551 (insert ins-string)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4552 (when (string-match "\\?" ins-string)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4553 (search-backward "?")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4554 (delete-char 1)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4555 (message "")
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4556
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4557 ;; Check if the prefix arg was numeric, and call recursively
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4558 (when (and (integerp arg)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4559 (> arg 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4560 (re-search-backward
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4561 "\\\\\\([a-zA-Z]*cite\\|cite[a-zA-Z]*\\)\\**\\(\\[[^]]*\\]\\)*{\\([^}]*\\)" nil t))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4562 (goto-char (match-end 0))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4563 (decf arg)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4564 (reftex-do-citation arg))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4565
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4566 ;; Return the citation key
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4567 (or (eq entry 'all)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4568 (reftex-get-bib-field "&key" entry)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4569
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4570 (defun reftex-insert-bib-matches (list)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4571 ;; 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
4572 (let ((mouse-face
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4573 (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
4574 reftex-mouse-selected-face
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4575 nil))
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4576 tmp len)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4577 (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4578 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4579 (lambda (x)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4580 (setq tmp (cdr (assoc "&formatted" x))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4581 len (length tmp))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4582 (put-text-property 0 len ':data x tmp)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4583 (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
4584 (insert tmp)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4585 list)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4586
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4587 (defun reftex-format-names (namelist n)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4588 (let (last (len (length namelist)))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4589 (cond
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4590 ((= 1 len) (car namelist))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4591 ((> 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
4592 (t
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4593 (setq n (min len n)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4594 last (nth (1- n) namelist))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4595 (setcdr (nthcdr (- n 2) namelist) nil)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4596 (concat
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4597 (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
4598 (nth 1 reftex-cite-punctuation)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4599 last)))))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4600
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4601 (defun reftex-format-citation (entry format)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4602 ;; 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
4603
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4604 (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
4605
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4606 (if (and reftex-comment-citations
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4607 (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
4608 (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
4609
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4610 (while (string-match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4611 "\\(\\`\\|[^%]\\)\\(\\(%\\([0-9]*\\)\\([a-zA-Z]\\)\\)[.,;: ]*\\)"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4612 format)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4613 (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
4614 (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
4615 rpl b e)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4616 (save-match-data
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4617 (setq rpl
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4618 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4619 ((= l ?l) (concat
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4620 (reftex-get-bib-field "&key" entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4621 (if reftex-comment-citations
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4622 reftex-cite-comment-format
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4623 "")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4624 ((= l ?a) (reftex-format-names
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4625 (reftex-get-bib-names "author" entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4626 (or n 2)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4627 ((= l ?A) (car (reftex-get-bib-names "author" entry)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4628 ((= l ?b) (reftex-get-bib-field "booktitle" entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4629 ((= 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
4630 ((= 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
4631 ((= l ?e) (reftex-format-names
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4632 (reftex-get-bib-names "editor" entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4633 (or n 2)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4634 ((= 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
4635 ((= 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
4636 ((= 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
4637 ((= 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
4638 ((= 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
4639 ((= 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
4640 ((= 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
4641 ((= 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
4642 ((= 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
4643 ((= l ?P) (car (split-string
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4644 (reftex-get-bib-field "pages" entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4645 "[- .]+")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4646 ((= 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
4647 ((= 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
4648 ((= 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
4649 ((= l ?t) (reftex-get-bib-field "title" entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4650 ((= 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
4651 ((= 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
4652
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4653 (if (string= rpl "")
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4654 (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
4655 (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
4656 (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
4657 (while (string-match "%%" format)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4658 (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
4659 (while (string-match "[ ,.;:]*%<" format)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4660 (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
4661 format)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4662
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4663 (defun reftex-bibtex-selection-callback (data ignore no-revisit)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4664 ;; 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
4665 ;; 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
4666 ;; recommended for follow mode. It works OK for individual lookups.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4667 (let ((win (selected-window))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4668 (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
4669 bibfile-list item tmp)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4670
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4671 (catch 'exit
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4672 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4673 (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
4674 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4675 ((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
4676 (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
4677 ((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
4678 (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
4679 item t))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4680 (reftex-default-bibliography
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4681 (setq bibfile-list reftex-default-bibliography))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4682 (t (ding) (throw 'exit))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4683
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4684 (when no-revisit
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4685 (setq bibfile-list
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4686 (delq nil (mapcar (lambda (x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4687 (if (get-file-buffer x) x nil))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4688 bibfile-list))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4689
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4690 (reftex-pop-to-bibtex-entry
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4691 key bibfile-list (not reftex-keep-temporary-buffers) t item))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4692
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4693 (select-window win)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4694
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4695 ;;; ===========================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4696 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4697 ;;; Here is the routine used for selection
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4698
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4699 ;; Marker for return point from recursive edit
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4700 (defvar reftex-recursive-edit-marker (make-marker))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4701
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4702 (defvar reftex-last-data nil)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4703 (defvar reftex-last-line nil)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4704
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4705 (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
4706 ;; 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
4707 ;; message if so.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4708 (if (marker-position reftex-recursive-edit-marker)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4709 (error
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4710 (substitute-command-keys
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4711 "In unfinished selection process. Finish, or abort with \\[abort-recursive-edit]."))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4712
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4713 (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
4714 &optional offset
21115
fea2f6a2818d 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21114
diff changeset
4715 call-back cb-flag)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4716 ;; 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
4717 ;; 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
4718 ;; selected.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4719 ;; 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
4720 ;; selection commands.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4721 ;; 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
4722 ;; 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
4723 ;; 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
4724 ;; 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
4725 ;; of the element.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4726 ;; 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
4727
21075
0c95fb73e090 1998-03-06 Carsten Dominik <cd@delysid.gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21002
diff changeset
4728 (let* (ev data last-data callback-fwd (selection-buffer (current-buffer)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4729
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4730 (setq ev
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4731 (catch 'myexit
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4732 (save-window-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4733 (setq truncate-lines t)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4734
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4735 ;; Find a good starting point
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4736 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4737 (offset
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4738 (goto-char
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4739 (or (and (listp offset)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4740 (text-property-any (point-min) (point-max)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4741 ':data offset))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4742 (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
4743 (boundp 'reftex-last-data)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4744 (listp reftex-last-data)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4745 (text-property-any (point-min) (point-max)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4746 ':data reftex-last-data))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4747 (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
4748 (boundp 'reftex-last-line)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4749 (integerp reftex-last-line)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4750 (progn (goto-line reftex-last-line) (point)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4751 (point-min))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4752 (t (goto-char (point-min))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4753 (beginning-of-line 1)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4754 (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
4755
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4756 (unwind-protect
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4757 (progn
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4758 (use-local-map keymap)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4759 (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
4760 (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
4761 (princ prompt)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4762 (set-marker reftex-recursive-edit-marker (point))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4763 (run-hooks 'post-command-hook) ;; because XEmacs does not do it
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4764 (recursive-edit))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4765
21075
0c95fb73e090 1998-03-06 Carsten Dominik <cd@delysid.gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21002
diff changeset
4766 (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
4767 (save-excursion
0c95fb73e090 1998-03-06 Carsten Dominik <cd@delysid.gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21002
diff changeset
4768 (set-buffer selection-buffer)
0c95fb73e090 1998-03-06 Carsten Dominik <cd@delysid.gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21002
diff changeset
4769 (use-local-map nil)
0c95fb73e090 1998-03-06 Carsten Dominik <cd@delysid.gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21002
diff changeset
4770 (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
4771 (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
4772 '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
4773
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4774 (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
4775 (+ (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
4776 (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
4777 (reftex-kill-buffer "*RefTeX Help*")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4778 (message "")
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4779 (list ev data last-data)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4780
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4781 ;; 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
4782 ;; 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
4783
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4784 (defvar found-list)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4785 (defvar cb-flag)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4786 (defvar data)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4787 (defvar prompt)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4788 (defvar last-data)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4789 (defvar call-back)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4790 (defvar help-string)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4791 (defvar callback-fwd)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4792 (defvar varioref)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4793
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4794 ;; The selection commands
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4795
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4796 (defun reftex-select-pre-command-hook ()
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4797 (reftex-unhighlight 1)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4798 (reftex-unhighlight 0))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4799
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4800 (defun reftex-select-post-command-hook ()
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4801 (let (b e)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4802 (setq data (get-text-property (point) ':data))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4803 (setq last-data (or data last-data))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4804
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4805 (when (and data cb-flag
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4806 (not (equal reftex-last-follow-point (point))))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4807 (setq reftex-last-follow-point (point))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4808 (funcall call-back data callback-fwd
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4809 (not reftex-revisit-to-follow)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4810 (if data
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4811 (setq b (or (previous-single-property-change
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4812 (1+ (point)) ':data)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4813 (point-min))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4814 e (or (next-single-property-change
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4815 (point) ':data)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4816 (point-max)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4817 (setq b (point) e (point)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4818 (and (memq reftex-highlight-selection '(cursor both))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4819 (reftex-highlight 1 b e))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4820 (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
4821 (not (pos-visible-in-window-p e)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4822 (recenter (/ (window-height) 2)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4823 (when (and (fboundp 'current-message)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4824 (not (current-message)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4825 (princ prompt))))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4826
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4827 (defun reftex-select-next (&optional arg)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4828 (interactive "p")
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4829 (setq callback-fwd t)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4830 (or (eobp) (forward-char 1))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4831 (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
4832 (beginning-of-line 1))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4833 (defun reftex-select-previous (&optional arg)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4834 (interactive "p")
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4835 (setq callback-fwd nil)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4836 (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
4837 (defun reftex-select-next-heading (&optional arg)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4838 (interactive "p")
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4839 (end-of-line)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4840 (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
4841 (beginning-of-line))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4842 (defun reftex-select-previous-heading (&optional arg)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4843 (interactive "p")
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4844 (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
4845 (defun reftex-select-quit ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4846 (interactive)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4847 (throw 'myexit nil))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4848 (defun reftex-select-keyboard-quit ()
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4849 (interactive)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4850 (throw 'exit t))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4851 (defun reftex-select-jump-to-previous ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4852 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4853 (let (pos)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4854 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4855 ((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
4856 reftex-last-data
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4857 (setq pos (text-property-any (point-min) (point-max)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4858 ':data reftex-last-data)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4859 (goto-char pos))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4860 ((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
4861 (integerp reftex-last-line))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4862 (goto-line reftex-last-line))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4863 (t (ding)))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4864 (defun reftex-select-toggle-follow ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4865 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4866 (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
4867 (defun reftex-select-toggle-varioref ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4868 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4869 (if (string= varioref "\\ref")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4870 (setq varioref "\\vref")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4871 (setq varioref "\\ref"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4872 (force-mode-line-update))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4873 (defun reftex-select-show-insertion-point ()
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4874 (interactive)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4875 (let ((this-window (selected-window)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4876 (unwind-protect
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4877 (progn
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4878 (switch-to-buffer-other-window
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4879 (marker-buffer reftex-select-return-marker))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4880 (goto-char (marker-position reftex-select-return-marker))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4881 (recenter (/ (window-height) 2)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4882 (select-window this-window))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4883 (defun reftex-select-callback ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4884 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4885 (if data (funcall call-back data callback-fwd nil) (ding)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4886 (defun reftex-select-accept ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4887 (interactive)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4888 (throw 'myexit 'return))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4889 (defun reftex-select-mouse-accept (ev)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4890 (interactive "e")
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4891 (mouse-set-point ev)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4892 (setq data (get-text-property (point) ':data))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4893 (setq last-data (or data last-data))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4894 (throw 'myexit 'return))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4895 (defun reftex-select-read-label ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4896 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4897 (let ((label (completing-read
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4898 "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
4899 nil nil reftex-prefix)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4900 (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
4901 (throw 'myexit label))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4902 (defun reftex-select-read-cite ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4903 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4904 (let* ((list (mapcar (lambda (x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4905 (cons (reftex-get-bib-field "&key" x) 1))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4906 found-list))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4907 (key (completing-read "Citation key: " list)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4908 (unless (equal key "")
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4909 (throw 'myexit key))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4910 (defun reftex-select-help ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4911 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4912 (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
4913 (princ help-string))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4914 (reftex-enlarge-to-fit "*RefTeX Help*" t))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4915
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4916 ;;; ===========================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4917 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4918 ;;; View cross references
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4919
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4920 (defun reftex-view-crossref (&optional arg)
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
4921 "View cross reference of \\ref or \\cite macro at point.
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
4922 If the macro at point is a \\ref, show the corresponding label definition.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4923 If it is a \\cite, show the BibTeX database entry or the \\bibitem.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4924 If there is no such macro at point, search forward to find one.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4925 When you call this function several times in direct succession, point will
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4926 move to view subsequent cross references further down in the buffer.
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4927 To cope with the plethora of variations in packages, this function
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4928 assumes any macro either starting with or ending in `ref' or `cite' to
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4929 contain cross references.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4930 When the LaTeX package `xr' is being used, this command will also view
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4931 crossreferences in external documents. However, this works correctly only
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4932 when the \\externaldocument macros are used with the optional label prefix
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4933 argument.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4934 With one or two C-u prefixes, enforce rescanning of the document.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4935 With argument t or 1, select the window showing the cross reference."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4936
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4937 (interactive "P")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4938
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4939 ;; See where we are.
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4940 (let* ((re "\\\\\\([a-z]*\\(cite\\|ref\\)\\|\\(cite\\|ref\\)[a-z]*\\)\\**\\(\\[[^{}]*\\]\\)?{")
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4941 (macro (car (car (reftex-what-macro t))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4942 (this-word (reftex-this-word "*a-zA-Z\\\\"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4943 (my-window (selected-window))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4944 pop-window cmd args point)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4945
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4946 (if (and macro
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4947 (string-match "\\`\\\\cite\\|\\`\\\\ref\\|cite\\'\\|ref\\'"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4948 macro))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4949 (and (setq macro (match-string 0 macro))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4950 (string-match "\\`\\\\" macro)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4951 (setq macro (substring macro 1)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4952 (setq macro nil))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4953
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4954 (if (and macro
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4955 (eq last-command this-command)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4956 (eq last-command 'reftex-view-crossref))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4957 (if (string= macro "cite")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4958 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4959 (skip-chars-forward "^},%")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4960 (while (and (eq (following-char) ?%)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4961 (or (beginning-of-line 2) t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4962 (skip-chars-forward " \t\n\r")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4963 (skip-chars-forward ",")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4964 (if (eq (following-char) ?})
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4965 (setq macro nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4966 (setq macro nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4967
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4968 (if (and (not macro)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4969 (or (not (string-match "\\`\\\\" this-word))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4970 (eq (following-char) ?\\)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4971 (search-backward "\\" nil t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4972 t))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4973 (if (interactive-p)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4974 ;; Only move far if this function was called directly
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4975 (and (re-search-forward re nil t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4976 (setq macro (or (match-string 2) (match-string 3))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4977 ;; The macro needs to be at point
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4978 (and (looking-at re)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4979 (setq macro (or (match-string 2) (match-string 3)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4980 (goto-char (match-end 0)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4981
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4982
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4983 (unless macro
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4984 (error "No cross reference to display"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4985
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4986 ;; Ensure access to scanning info
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4987 (reftex-access-scan-info current-prefix-arg)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4988
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4989 (cond
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4990 ((string= macro "cite")
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4991 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4992 ((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
4993 (setq cmd 'reftex-pop-to-bibtex-entry
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4994 args (list
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4995 (reftex-this-word "^{},%\n\r")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4996 (reftex-get-bibfile-list) nil t)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4997 ((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
4998 (setq cmd 'reftex-pop-to-bibtex-entry
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4999 args (list
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5000 (reftex-this-word "^{},%\n\r")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5001 (list (cdr (assq 'thebib
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5002 (symbol-value reftex-docstruct-symbol))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5003 nil t t)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5004 (t (error "Cannot display crossref\n"))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5005 ((string= macro "ref")
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5006 (let* ((label (reftex-this-word "^{}%\n\r"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5007 (xr-data (assoc 'xr (symbol-value reftex-docstruct-symbol)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5008 (xr-re (nth 2 xr-data))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5009 (entry (assoc label (symbol-value reftex-docstruct-symbol))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5010
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5011 (if (and (not entry) (string-match xr-re label))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5012 ;; Label is defined in external document
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5013 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5014 (save-match-data
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5015 (set-buffer
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5016 (or (reftex-get-file-buffer-force
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5017 (cdr (assoc (match-string 1 label) (nth 1 xr-data))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5018 (error "Problem with external label %s" label))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5019 (setq label (substring label (match-end 1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5020 (reftex-access-scan-info)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5021 (setq entry
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5022 (assoc label (symbol-value reftex-docstruct-symbol)))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5023 (if entry
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5024 (setq cmd 'reftex-pop-to-label
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5025 args (list label (list (nth 3 entry)) nil t))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5026 (error "Label %s not known - reparse document might help" label))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5027 (t (error "This should not happen (reftex-view-crossref)")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5028 (setq point (point))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5029 (apply cmd args)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5030 (setq pop-window (selected-window))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5031 (add-hook 'pre-command-hook 'reftex-highlight-shall-die)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5032 (select-window my-window)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5033 (goto-char point)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5034 (when (or (equal arg t) (equal arg 1))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5035 (select-window pop-window))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5036
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5037 (defun reftex-mouse-view-crossref (ev)
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
5038 "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
5039 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
5040 If it is a \\cite, show the BibTeX database entry.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5041 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
5042 With argument, actually select the window showing the cross reference."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5043 (interactive "e")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5044 (mouse-set-point ev)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5045 (reftex-view-crossref current-prefix-arg))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5046
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5047 ;;; ===========================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5048 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5049 ;;; Functions that check out the surroundings
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5051 (defun reftex-what-macro (which &optional bound)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5052 ;; 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
5053 ;; 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
5054
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5055 ;; If WHICH is nil, immediately return nil.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5056 ;; If WHICH is t, return list of all macros enclosing point.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5057 ;; 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
5058 ;; name of the first macro in this list found to enclose point.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5059 ;; 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
5060 ;; 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
5061 ;; like statement.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5062
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5063 ;; 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
5064 ;; 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
5065 ;; 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
5066 ;; considered an argument of macro \macro.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5067
21124
2089d9bfb3d7 (reftex-nicify-text): make a new " " string each time.
Carsten Dominik <dominik@science.uva.nl>
parents: 21115
diff changeset
5068 (unless reftex-section-regexp (reftex-compute-ref-cite-tables))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5069 (catch 'exit
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5070 (if (null which) (throw 'exit nil))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5071 (let ((bound (or bound (save-excursion (re-search-backward
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5072 reftex-section-regexp nil 1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5073 (point))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5074 pos cmd-list cmd cnt cnt-opt entry)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5075 (save-restriction
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5076 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5077 (narrow-to-region (max 1 bound) (point-max))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5078 ;; move back out of the current parenthesis
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5079 (while (condition-case nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5080 (progn (up-list -1) t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5081 (error nil))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5082 (setq cnt 1 cnt-opt 0)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5083 ;; 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
5084 (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
5085 (condition-case nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5086 (progn (backward-sexp) t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5087 (error nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5088 (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
5089 (incf cnt))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5090 (setq pos (point))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5091 (when (and (or (= (following-char) ?\[)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5092 (= (following-char) ?\{))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5093 (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
5094 (setq cmd (reftex-match-string 0))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5095 (when (looking-at "\\\\begin{[^}]*}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5096 (setq cmd (reftex-match-string 0)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5097 cnt (1- cnt)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5098 ;; 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
5099 (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
5100 (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
5101 (setq cmd nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5102 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5103 ((null cmd))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5104 ((eq t which)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5105 (push (cons cmd (point)) cmd-list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5106 ((member cmd which)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5107 (throw 'exit (cons cmd (point))))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5108 (goto-char pos)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5109 (nreverse cmd-list)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5110
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5111 (defun reftex-what-environment (which &optional bound)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5112 ;; 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
5113 ;; 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
5114 ;; them.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5115
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5116 ;; If WHICH is nil, immediately return nil.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5117 ;; If WHICH is t, return list of all environments enclosing point.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5118 ;; 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
5119 ;; 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
5120 ;; point.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5121
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5122 ;; 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
5123 ;; 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
5124
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5125 (catch 'exit
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5126 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5127 (if (null which) (throw 'exit nil))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5128 (let ((bound (or bound (save-excursion (re-search-backward
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5129 reftex-section-regexp nil 1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5130 (point))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5131 env-list end-list env)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5132 (while (re-search-backward "\\\\\\(begin\\|end\\){\\([^}]+\\)}"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5133 bound t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5134 (setq env (buffer-substring-no-properties
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5135 (match-beginning 2) (match-end 2)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5136 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5137 ((string= (match-string 1) "end")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5138 (add-to-list 'end-list env))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5139 ((member env end-list)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5140 (setq end-list (delete env end-list)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5141 ((eq t which)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5142 (push (cons env (point)) env-list))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5143 ((member env which)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5144 (throw 'exit (cons env (point))))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5145 (nreverse env-list)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5146
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5147 ;; ============================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5148 ;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5149 ;; Some generally useful functions
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5150
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5151 (defun reftex-no-props (string)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5152 ;; Return STRING with all text properties removed
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5153 (and (stringp string)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5154 (set-text-properties 0 (length string) nil string))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5155 string)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5156
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5157 (defun reftex-match-string (n)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5158 ;; Match string without properties
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5159 (when (match-beginning n)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5160 (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
5161
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5162 (defun reftex-kill-buffer (buffer)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5163 ;; 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
5164 (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
5165 (kill-buffer buffer)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5166
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5167 (defun reftex-erase-buffer (&optional buffer)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5168 ;; 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
5169 ;; This even erases read-only buffers.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5170 (cond
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5171 ((null buffer)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5172 ;; erase current buffer
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5173 (let ((buffer-read-only nil)) (erase-buffer)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5174 ((setq buffer (get-buffer buffer))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5175 ;; buffer exists
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5176 (save-excursion
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5177 (set-buffer buffer)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5178 (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
5179
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5180 (defun reftex-this-word (&optional class)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5181 ;; Grab the word around point.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5182 (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
5183 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5184 (buffer-substring-no-properties
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5185 (progn (skip-chars-backward class) (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5186 (progn (skip-chars-forward class) (point)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5187
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5188 (defvar enable-multibyte-characters)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5189 (defun reftex-truncate (string ncols &optional ellipses padding)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5190 ;; Truncate a string to NCHAR characters.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5191 ;; Works fast with ASCII and correctly with Mule characters.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5192 ;; When ELLIPSES is non-nil, put three dots at the end of the string.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5193 (setq string
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5194 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5195 ((and (boundp 'enable-multibyte-characters)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5196 enable-multibyte-characters)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5197 (if (<= (string-width string) ncols)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5198 string
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5199 (if ellipses
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5200 (concat (truncate-string-to-width string (- ncols 3)) "...")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5201 (truncate-string-to-width string ncols))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5202 (t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5203 (if (<= (length string) ncols)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5204 string
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5205 (if ellipses
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5206 (concat (substring string 0 (- ncols 3)) "...")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5207 (substring string 0 ncols))))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5208 (if padding
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5209 (format (format "%%-%ds" ncols) string)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5210 string))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5211
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5212 (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
5213 ;; 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
5214 ;; 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
5215 ;; 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
5216 (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
5217 (goto-char start)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5218 (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
5219 (setq match1 (match-data)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5220 (goto-char start)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5221 (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
5222 (setq match2 (match-data)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5223 (goto-char start)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5224 (setq match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5225 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5226 ((not match1) match2)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5227 ((not match2) match1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5228 ((< (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
5229 (t match2)))
21170
dbe101f49d57 (reftex-nearest-match): store-match-data => set-match-data.
Richard M. Stallman <rms@gnu.org>
parents: 21130
diff changeset
5230 (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
5231
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5232 (defun reftex-auto-mode-alist ()
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5233 ;; 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
5234 ;; Stolen from gnus nnheader.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5235 (let ((alist auto-mode-alist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5236 out)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5237 (while alist
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5238 (when (listp (cdr (car alist)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5239 (push (car alist) out))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5240 (pop alist))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5241 (nreverse out)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5242
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5243 (defun reftex-enlarge-to-fit (buf2 &optional keep-current)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5244 ;; Enlarge other window displaying buffer without killing current window
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5245 ;; 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
5246 (let* ((win1 (selected-window))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5247 (buf1 (current-buffer))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5248 (win2 (get-buffer-window buf2)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5249 (when win2
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5250 (select-window win2)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5251 (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
5252 (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
5253 (enlarge-window (1+ (- (count-lines 1 (point-max))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5254 (window-height))))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5255 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5256 ((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
5257 (keep-current
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5258 ;; 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
5259 (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
5260 (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
5261
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5262 (defun reftex-access-search-path (which &optional recurse file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5263 ;; Access path from environment variables. WHICH is either "tex" or "bib".
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5264 ;; When RECURSE is t, expand recursive paths, ending in double slash.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5265 ;; FILE is just for the message.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5266 (let* ((pathvar (intern (concat "reftex-" which "-path")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5267 (status (get pathvar 'status)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5268 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5269 ((eq status 'recursed))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5270 ((and status (null recurse)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5271 ((null status)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5272 (let ((env-vars (if (equal which "tex") (list "TEXINPUTS")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5273 reftex-bibpath-environment-variables)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5274 (set pathvar (reftex-parse-colon-path
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5275 (mapconcat (function (lambda(x) (or (getenv x) "")))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5276 env-vars path-separator))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5277 (put pathvar 'status 'split))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5278 ((and (eq 'split status) recurse)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5279 (message "Expanding search path to find %s file: %s ..." which file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5280 (set pathvar (reftex-expand-path (symbol-value pathvar)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5281 (put pathvar 'status 'recursed)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5282
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5283 (defun reftex-find-file-on-path (file path)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5284 ;; Find FILE along the directory list PATH.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5285 (catch 'exit
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5286 (when (file-name-absolute-p file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5287 (if (file-exists-p file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5288 (throw 'exit file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5289 (throw 'exit nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5290 (let* ((thepath path) file1 dir
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5291 (doubleslash (concat "/" "/")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5292 (while (setq dir (pop thepath))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5293 (when (string= (substring dir -2) doubleslash)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5294 (setq dir (substring dir 0 -1)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5295 (setq file1 (expand-file-name file (expand-file-name dir)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5296 (if (file-exists-p file1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5297 (throw 'exit file1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5298 ;; No such file
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5299 nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5300
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5301 (defun reftex-parse-colon-path (path)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5302 ;; Like parse-colon-parse, but // or /~ have no effects.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5303 (mapcar 'file-name-as-directory
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5304 (delete "" (split-string path (concat path-separator "+")))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5305
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5306 (defun reftex-expand-path (path)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5307 ;; Expand parts of path ending in a double slash
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5308 (let (path1 dir dirs (doubleslash (concat "/" "/")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5309 (while (setq dir (pop path))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5310 (if (string= (substring dir -2) doubleslash)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5311 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5312 (setq dir (substring dir 0 -1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5313 (setq dirs (reftex-recursive-directory-list dir))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5314 (setq path1 (append dirs path1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5315 (push dir path1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5316 (nreverse path1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5317
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5318 (defun reftex-recursive-directory-list (dir)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5319 (let ((path (list dir)) dirs path1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5320 (while (setq dir (pop path))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5321 (setq dirs
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5322 (delete nil
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5323 (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5324 (function
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5325 (lambda (x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5326 (if (and (file-directory-p x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5327 (not (string-match "/\\.+\\'" x)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5328 (file-name-as-directory x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5329 nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5330 (directory-files dir t))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5331 (setq path (append dirs path))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5332 (push dir path1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5333 path1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5334
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5335 (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
5336 ;; 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
5337 (let ((start -2))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5338 (setq string (regexp-quote string))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5339 (while (setq start (string-match "[\n\r]" string (+ 3 start)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5340 (setq string (replace-match "[\n\r]" nil t string)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5341 string))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5342
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5343 (defun reftex-make-desperate-section-regexp (old)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5344 ;; Return a regexp which will still match a section statement even if
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5345 ;; x-symbol or isotex or the like have been at work in the mean time.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5346 (let* ((n (1+ (string-match "[[{]" old)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5347 (new (regexp-quote (substring old 0 (1+ (string-match "[[{]" old)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5348 (old (substring old n)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5349 (while (string-match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5350 "\\([\r\n]\\)\\|\\(\\`\\|[ \t\n\r]\\)\\([a-zA-Z0-9]+\\)\\([ \t\n\r]\\|}\\'\\)"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5351 old)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5352 (if (match-beginning 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5353 (setq new (concat new "[^\n\r]*[\n\r]"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5354 (setq new (concat new "[^\n\r]*" (match-string 3 old))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5355 (setq old (substring old (match-end 0))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5356 new))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5357
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5358 (defun reftex-delete-list (elt-list list)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5359 ;; like delete, but with a list of things to delete
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5360 ;; (original code from Rory Molinari)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5361 (while elt-list
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5362 (setq list (delete (car elt-list) list)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5363 elt-list (cdr elt-list)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5364 list)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5365
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5366 (defun reftex-get-buffer-visiting (file)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5367 ;; return a buffer visiting FILE
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5368 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5369 ((boundp 'find-file-compare-truenames) ; XEmacs
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5370 (let ((find-file-compare-truenames t))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5371 (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
5372 ((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
5373 (find-buffer-visiting file))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5374 (t (error "This should not happen (reftex-get-buffer-visiting)"))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5375
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5376 (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
5377 ;; 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
5378 ;; If neither such a buffer nor the file exist, return nil.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5379 ;; If MARK-TO-KILL is t and there is no live buffer, load the file with
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5380 ;; 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
5381 ;; and mark the buffer to be killed after use.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5382
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5383 (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
5384
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5385 (cond (buf
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5386 ;; 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
5387 buf)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5388
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5389 ((file-readable-p file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5390 ;; 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
5391
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5392 (if (or (not mark-to-kill)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5393 (eq t reftex-initialize-temporary-buffers))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5394
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5395 ;; Visit the file with full magic
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5396 (setq buf (find-file-noselect file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5397
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5398 ;; 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
5399 ;; with limited Magic
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5400
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5401 ;; The magic goes away
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5402 (let ((format-alist nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5403 (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
5404 (default-major-mode 'fundamental-mode)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5405 (enable-local-variables nil)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5406 (after-insert-file-functions nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5407 (setq buf (find-file-noselect file)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5408
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5409 ;; Is there a hook to run?
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5410 (when (listp reftex-initialize-temporary-buffers)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5411 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5412 (set-buffer buf)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5413 (run-hooks 'reftex-initialize-temporary-buffers))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5414
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5415 ;; 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
5416 (and mark-to-kill
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5417 (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
5418
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5419 ;; Return the new buffer
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5420 buf)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5421
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5422 ;; 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
5423 (t nil))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5424
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5425 (defun reftex-splice-symbols-into-list (list alist)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5426 ;; 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
5427 ;; Return new list.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5428 (let (rtn tmp)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5429 (while list
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5430 (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
5431 (symbolp (car list)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5432 (setq tmp (car list))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5433 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5434 ((assoc tmp alist)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
5435 (setq list (append (nth 2 (assoc tmp alist)) (cdr list))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5436 (t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5437 (error "Cannot treat symbol %s in reftex-label-alist"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5438 (symbol-name tmp)))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5439 (push (pop list) rtn))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5440 (nreverse rtn)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5441
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5442 (defun reftex-uniquify (alist &optional keep-list)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
5443 ;; 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
5444 ;; Elements of KEEP-LIST are not removed even if duplicate.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5445 (let (new elm)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5446 (while alist
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5447 (setq elm (pop alist))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5448 (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
5449 (not (assoc (car elm) new)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5450 (push elm new)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5451 (nreverse new)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5452
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5453 (defun reftex-use-fonts ()
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
5454 ;; Return t if we can and want to use fonts.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5455 (and window-system
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5456 reftex-use-fonts
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5457 (featurep 'font-lock)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5458
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5459 (defun reftex-refontify ()
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5460 ;; 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
5461 (and (reftex-use-fonts)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5462 (or (eq t reftex-refontify-context)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5463 (and (eq 1 reftex-refontify-context)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5464 (or (featurep 'x-symbol))))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5465
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5466 (defun reftex-fontify-select-label-buffer ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5467 ;; Fontify the `*RefTeX Select*' buffer
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5468 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5469 ((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
5470 ;; Good: we have the indirection functions, and can support lazy-lock etc.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5471 (set (make-local-variable 'font-lock-fontify-region-function)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5472 'reftex-select-font-lock-fontify-region)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5473 (let ((major-mode 'latex-mode))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5474 (font-lock-mode 1)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5475 ((fboundp 'font-lock-set-defaults-1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5476 ;; Looks like the XEmacs font-lock stuff.
21130
60e882bbb28b Added keybinding for `reftex-mouse-view-crossref' to S-mouse-2.
Carsten Dominik <dominik@science.uva.nl>
parents: 21124
diff changeset
5477 ;; FIXME: this is still kind of a hack, but might go away some day.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5478 (set (make-local-variable 'font-lock-keywords) nil)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5479 (let ((major-mode 'latex-mode)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5480 (font-lock-defaults-computed nil))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5481 (font-lock-set-defaults-1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5482 (reftex-select-font-lock-fontify-region (point-min) (point-max))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5483 (t
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5484 ;; Oops?
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5485 (message "Sorry: cannot refontify RefTeX Select buffer."))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5486
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5487 (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
5488 ;; 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
5489 (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
5490 'font-lock-default-fontify-region
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5491 'font-lock-fontify-region))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5492 beg1 end1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5493 (goto-char beg)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5494 (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
5495 (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
5496 (funcall func beg1 end1 nil)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5497 (goto-char end1))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5498
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
5499 ;; Highlighting uses overlays. If this is for XEmacs, we need to load
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5500 ;; the overlay library, available in version 19.15
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5501 (and (not (fboundp 'make-overlay))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5502 (condition-case nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5503 (require 'overlay)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5504 (error
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5505 (error "RefTeX needs overlay emulation (available in XEmacs 19.15)"))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5506
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5507 ;; 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
5508 (defvar reftex-highlight-overlays [nil nil])
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5509
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5510 ;; Initialize the overlays
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5511 (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
5512 (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
5513 'face 'highlight)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5514 (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
5515 (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
5516 'face reftex-cursor-selected-face)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5517
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5518 ;; Two functions for activating and deactivation highlight overlays
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5519 (defun reftex-highlight (index begin end &optional buffer)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5520 "Highlight a region with overlay INDEX."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5521 (move-overlay (aref reftex-highlight-overlays index)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5522 begin end (or buffer (current-buffer))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5523 (defun reftex-unhighlight (index)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5524 "Detach overlay INDEX."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5525 (delete-overlay (aref reftex-highlight-overlays index)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5526
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5527 (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
5528 ;; Function used in pre-command-hook to remove highlights.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5529 (remove-hook 'pre-command-hook 'reftex-highlight-shall-die)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5530 (reftex-unhighlight 0))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5531
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5532 ;;; ---------------------------------------------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5533 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5534 ;;; Functions to compile the tables, reset the mode etc.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5535
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5536 (defun reftex-reset-mode ()
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
5537 "Reset RefTeX Mode. Required to implement changes to some list variables.
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
5538 This function will compile the information in `reftex-label-alist' and similar
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
5539 variables. It is called when RefTeX is first used, and after changes to
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5540 these variables."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5541 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5542
18219
aaeaae005e98 Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents: 18123
diff changeset
5543 ;; Record that we have done this
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5544 (setq reftex-tables-dirty nil)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5545 (setq reftex-memory
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5546 (list reftex-label-alist reftex-label-alist-external-add-ons
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5547 reftex-default-label-alist-entries))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5548
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5549 ;; Reset the file search path variables
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5550 (put 'reftex-tex-path 'status nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5551 (put 'reftex-bib-path 'status nil)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5552
18219
aaeaae005e98 Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents: 18123
diff changeset
5553 ;; 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
5554 ;; 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
5555 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5556 (let ((buffer-list '("*RefTeX Help*" "*RefTeX Select*"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5557 "*Duplicate Labels*" "*toc*" "*RefTeX-scratch*"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5558 buf)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5559 (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
5560 (if (get-buffer buf)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5561 (kill-buffer buf))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5562 (reftex-erase-all-selection-buffers))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5563
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5564 ;; 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
5565 (reftex-reset-scanning-information)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
5566
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5567 ;; Plug functions into AUCTeX if the user option says so.
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
5568 (reftex-plug-into-AUCTeX)
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
5569
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5570 (message "updating internal tables...")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5571 (reftex-compute-ref-cite-tables)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
5572 (message "updating internal tables... done"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5573
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5574 (defun reftex-reset-scanning-information ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5575 "Reset the symbols containing information from buffer scanning.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5576 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
5577 (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
5578 (reftex-erase-buffer "*toc*"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5579 (let ((symlist reftex-multifile-symbols)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5580 symbol)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5581 (while symlist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5582 (setq symbol (car symlist)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5583 symlist (cdr symlist))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5584 (if (and (symbolp (symbol-value symbol))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5585 (not (null (symbol-value symbol))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5586 (set (symbol-value symbol) nil)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5587
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5588 (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
5589 ;; Remove all selection buffers associated with current document.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5590 (mapcar (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5591 (lambda (type)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5592 (reftex-erase-buffer (reftex-make-selection-buffer-name type))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5593 reftex-typekey-list))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5594
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5595 (defun reftex-compute-ref-cite-tables ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5596 ;; Update ref and cite tables
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5597
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5598 ;; Update AUCTeX style information
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5599 (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
5600 (condition-case nil (TeX-update-style) (error nil)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5601
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5602 ;; Compile information in reftex-label-alist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5603 (let ((tmp (reftex-uniquify (reftex-splice-symbols-into-list
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5604 (append
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5605 reftex-label-alist
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5606 reftex-label-alist-external-add-ons
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5607 reftex-default-label-alist-entries)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5608 reftex-label-alist-builtin)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5609 '(nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5610 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
5611 fmt reffmt labelfmt wordlist qh-list macros-with-labels
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5612 nargs nlabel opt-args cell sum i words-are-re)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5613
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5614 (setq reftex-words-to-typekey-alist nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5615 reftex-typekey-list nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5616 reftex-typekey-to-format-alist nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5617 reftex-typekey-to-prefix-alist nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5618 reftex-env-or-mac-alist nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5619 reftex-label-env-list nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5620 reftex-label-mac-list nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5621 (while tmp
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5622 (catch 'next-entry
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5623 (setq entry (car tmp)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5624 env-or-mac (car entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5625 entry (cdr entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5626 tmp (cdr tmp))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5627 (if (null env-or-mac)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5628 (setq env-or-mac ""))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5629 (if (stringp (car entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5630 ;; 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
5631 ;; 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
5632 (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
5633 (cons (concat (car entry) ":")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5634 (cdr entry)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5635 (setq typekeychar (nth 0 entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5636 typekey (char-to-string typekeychar)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5637 prefix (nth 1 entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5638 fmt (nth 2 entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5639 context (nth 3 entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5640 wordlist (nth 4 entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5641 (if (stringp wordlist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5642 ;; 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
5643 (setq wordlist (nthcdr 4 entry)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5644
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5645 (if (and (stringp fmt)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5646 (string-match "@" fmt))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5647 ;; special syntax for specifying a label format
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5648 (setq fmt (split-string fmt "@+"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5649 (setq fmt (list "\\label{%s}" fmt)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5650 (setq labelfmt (car fmt)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5651 reffmt (nth 1 fmt))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5652 (if typekey
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5653 (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
5654 (if (and typekey prefix
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5655 (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
5656 (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
5657 (cons typekey prefix)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5658 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5659 ((string-match "\\`\\\\" env-or-mac)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5660 ;; It's a macro
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5661 (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
5662 (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
5663 nargs (second result)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5664 nlabel (third result)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5665 opt-args (fourth result))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5666 (if nlabel (add-to-list 'macros-with-labels env-or-mac)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5667 (add-to-list 'reftex-label-mac-list env-or-mac))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5668 (t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5669 (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
5670 (cond ((string= env-or-mac "any"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5671 ((string= env-or-mac ""))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5672 ((string= env-or-mac "section"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5673 (t
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5674 (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
5675 ;; Translate some special context cases
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5676 (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
5677 (setq context
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5678 (format
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5679 (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
5680 (regexp-quote env-or-mac))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5681 (and reffmt
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5682 (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
5683 (push (cons typekey reffmt) reftex-typekey-to-format-alist))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5684 (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
5685 (not (string= env-or-mac ""))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5686 (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
5687 (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
5688 nargs nlabel opt-args)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5689 reftex-env-or-mac-alist))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5690 (if (eq (car wordlist) 'regexp)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5691 (setq wordlist (cdr wordlist)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5692 words-are-re t)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5693 (setq words-are-re nil))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5694 (while (and (setq word (pop wordlist))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5695 (stringp word))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5696 (setq word (identity (if words-are-re word (regexp-quote word))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5697 (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
5698 (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
5699 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5700 ((string= "" env-or-mac) nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5701 ((setq cell (assoc typekey qh-list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5702 (push env-or-mac (cdr cell)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5703 (t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5704 (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
5705
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5706 (setq qh-list
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5707 (sort qh-list (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5708 (lambda (x1 x2) (string< (car x1) (car x2))))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5709 (setq reftex-typekey-to-prefix-alist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5710 (nreverse reftex-typekey-to-prefix-alist))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5711 (setq reftex-type-query-prompt
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5712 (concat "Label type: "
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5713 (mapconcat (function (lambda(x) (format "[%s]" (car x))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5714 qh-list " ")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5715 " (?=Help)"))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5716 (setq reftex-type-query-help
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5717 (concat "SELECT A LABEL TYPE:\n--------------------\n"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5718 (mapconcat
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5719 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5720 (lambda(x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5721 (setq sum 0)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5722 (format " [%s] %s"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5723 (car x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5724 (mapconcat
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5725 (lambda(x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5726 (setq sum (+ sum (length x)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5727 (if (< sum 60)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5728 x
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5729 (setq sum 0)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5730 (concat "\n " x)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5731 (cdr x) " "))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5732 qh-list "\n")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5733
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5734 ;; Convert magic words to regular expressions
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5735 (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
5736 (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5737 (lambda (x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5738 (setq word (car x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5739 typekey (cdr x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5740 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
5741 (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
5742 (setq i 0)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5743 (while (and (< i 10)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5744 (< i (length fmt))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5745 (not (member (aref fmt i) '(?%))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5746 (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
5747 (substring fmt 0 (1+ i)))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5748 (incf i))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5749 (cons (concat word "\\)\\=") typekey))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5750 (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
5751
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5752 ;; Calculate the regular expressions
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5753 (let ((label-re "\\\\label{\\([^}]*\\)}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5754 (include-re "\\(\\`\\|[\n\r]\\)[ \t]*\\\\\\(include\\|input\\)[{ \t]+\\([^} \t\n\r]+\\)")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5755 (section-re
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5756 (concat "\\(\\`\\|[\n\r]\\)[ \t]*\\\\\\("
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5757 (mapconcat 'car reftex-section-levels "\\|")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5758 "\\)\\*?\\(\\[[^]]*\\]\\)?{"))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5759 (appendix-re "\\(\\`\\|[\n\r]\\)[ \t]*\\(\\\\appendix\\)")
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5760 (macro-re
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5761 (if macros-with-labels
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5762 (concat "\\("
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5763 (mapconcat 'regexp-quote macros-with-labels "\\|")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5764 "\\)[[{]")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5765 ""))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5766 (find-label-re-format
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5767 (concat "\\("
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5768 (mapconcat 'regexp-quote (append '("\\label")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5769 macros-with-labels) "\\|")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5770 "\\)\\([[{][^]}]*[]}]\\)*[[{]\\(%s\\)[]}]")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5771 (setq reftex-section-regexp section-re
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5772 reftex-section-or-include-regexp
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5773 (concat section-re "\\|" include-re)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5774 reftex-everything-regexp
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5775 (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
5776 "\\|" appendix-re
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5777 (if macros-with-labels "\\|" "") macro-re)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5778 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
5779 reftex-find-label-regexp-format2
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5780 "\\([]} \t\n\r]\\)\\([[{]\\)\\(%s\\)[]}]"))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5781
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5782 ;;; Keybindings --------------------------------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5783
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5784 (define-key reftex-mode-map "\C-c=" 'reftex-toc)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5785 (define-key reftex-mode-map "\C-c(" 'reftex-label)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5786 (define-key reftex-mode-map "\C-c)" 'reftex-reference)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5787 (define-key reftex-mode-map "\C-c[" 'reftex-citation)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5788 (define-key reftex-mode-map "\C-c&" 'reftex-view-crossref)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5789
21130
60e882bbb28b Added keybinding for `reftex-mouse-view-crossref' to S-mouse-2.
Carsten Dominik <dominik@science.uva.nl>
parents: 21124
diff changeset
5790 ;; Bind `reftex-mouse-view-crossref' only when the key is still free
60e882bbb28b Added keybinding for `reftex-mouse-view-crossref' to S-mouse-2.
Carsten Dominik <dominik@science.uva.nl>
parents: 21124
diff changeset
5791 (if (string-match "XEmacs" emacs-version)
60e882bbb28b Added keybinding for `reftex-mouse-view-crossref' to S-mouse-2.
Carsten Dominik <dominik@science.uva.nl>
parents: 21124
diff changeset
5792 (unless (key-binding [(shift button2)])
60e882bbb28b Added keybinding for `reftex-mouse-view-crossref' to S-mouse-2.
Carsten Dominik <dominik@science.uva.nl>
parents: 21124
diff changeset
5793 (define-key reftex-mode-map [(shift button2)]
60e882bbb28b Added keybinding for `reftex-mouse-view-crossref' to S-mouse-2.
Carsten Dominik <dominik@science.uva.nl>
parents: 21124
diff changeset
5794 'reftex-mouse-view-crossref))
60e882bbb28b Added keybinding for `reftex-mouse-view-crossref' to S-mouse-2.
Carsten Dominik <dominik@science.uva.nl>
parents: 21124
diff changeset
5795 (unless (key-binding [(shift mouse-2)])
60e882bbb28b Added keybinding for `reftex-mouse-view-crossref' to S-mouse-2.
Carsten Dominik <dominik@science.uva.nl>
parents: 21124
diff changeset
5796 (define-key reftex-mode-map [(shift mouse-2)]
60e882bbb28b Added keybinding for `reftex-mouse-view-crossref' to S-mouse-2.
Carsten Dominik <dominik@science.uva.nl>
parents: 21124
diff changeset
5797 'reftex-mouse-view-crossref)))
60e882bbb28b Added keybinding for `reftex-mouse-view-crossref' to S-mouse-2.
Carsten Dominik <dominik@science.uva.nl>
parents: 21124
diff changeset
5798
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5799 ;; If the user requests so, she can have a few more bindings:
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5800 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5801 (reftex-extra-bindings
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5802 (define-key reftex-mode-map "\C-ct" 'reftex-toc)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5803 (define-key reftex-mode-map "\C-cl" 'reftex-label)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5804 (define-key reftex-mode-map "\C-cr" 'reftex-reference)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5805 (define-key reftex-mode-map "\C-cc" 'reftex-citation)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5806 (define-key reftex-mode-map "\C-cv" 'reftex-view-crossref)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5807 (define-key reftex-mode-map "\C-cg" 'reftex-grep-document)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5808 (define-key reftex-mode-map "\C-cs" 'reftex-search-document)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5809
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5810 ;; Selection Keymaps
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5811 (let ((map (make-sparse-keymap)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5812 ; First, the common stuff
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5813 (substitute-key-definition
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5814 '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
5815 (substitute-key-definition
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5816 '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
5817 (substitute-key-definition
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5818 '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
5819 (substitute-key-definition
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5820 'newline 'reftex-select-accept map global-map)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5821 (define-key map " " 'reftex-select-callback)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5822 (define-key map "n" 'reftex-select-next)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5823 (define-key map [(down)] 'reftex-select-next)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5824 (define-key map "p" 'reftex-select-previous)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5825 (define-key map [(up)] 'reftex-select-previous)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5826 (define-key map "f" 'reftex-select-toggle-follow)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5827 (define-key map "\C-m" 'reftex-select-accept)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5828 (define-key map [(return)] 'reftex-select-accept)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5829 (define-key map "q" 'reftex-select-quit)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5830 (define-key map "." 'reftex-select-show-insertion-point)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5831 (define-key map "?" 'reftex-select-help)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5832 (if (string-match "XEmacs" emacs-version)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5833 (define-key map [(button2)] 'reftex-select-mouse-accept) ; XEmacs
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5834 (define-key map [(mouse-2)] 'reftex-select-mouse-accept)) ; Emacs
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5835
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5836 (loop for key across "0123456789" do
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5837 (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
5838 (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
5839
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5840 (setq reftex-select-label-map map)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5841 (setq reftex-select-bib-map (copy-keymap map))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5842
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5843 ;; Now the rest
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5844
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5845 (loop for key across "cgilrRstx#%" do
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5846 (define-key reftex-select-label-map (vector (list key))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5847 (list 'lambda '() '(interactive) (list 'throw '(quote myexit) key))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5848 (define-key reftex-select-label-map "b" 'reftex-select-jump-to-previous)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5849 (define-key reftex-select-label-map "v" 'reftex-select-toggle-varioref)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5850 (define-key reftex-select-label-map [(tab)] 'reftex-select-read-label)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5851 (define-key reftex-select-label-map "\C-i" 'reftex-select-read-label)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5852 (define-key reftex-select-label-map "\C-c\C-n" 'reftex-select-next-heading)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5853 (define-key reftex-select-label-map "\C-c\C-p" 'reftex-select-previous-heading)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5854
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5855 (loop for key across "grRa" do
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5856 (define-key reftex-select-bib-map (vector (list key))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5857 (list 'lambda '() '(interactive) (list 'throw '(quote myexit) key))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5858 (define-key reftex-select-bib-map "\C-i" 'reftex-select-read-cite)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5859 (define-key reftex-select-bib-map [(tab)] 'reftex-select-read-cite))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5860
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5861 ;; Table of Contents map
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5862 (let ((map reftex-toc-map))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5863 (if (string-match "XEmacs" emacs-version)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5864 (define-key map [(button2)] 'reftex-toc-mouse-goto-line-and-hide);XEmacs
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5865 (define-key map [(mouse-2)] 'reftex-toc-mouse-goto-line-and-hide)) ;Emacs
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5866 (define-key map "n" 'next-line)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5867 (define-key map "p" 'previous-line)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5868 (define-key map "?" 'reftex-toc-show-help)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5869 (define-key map " " 'reftex-toc-view-line)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5870 (define-key map "\C-m" 'reftex-toc-goto-line-and-hide)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5871 (define-key map "\C-i" 'reftex-toc-goto-line)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5872 (define-key map "r" 'reftex-toc-rescan)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5873 (define-key map "R" 'reftex-toc-Rescan)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5874 (define-key map "g" 'revert-buffer)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5875 (define-key map "q" 'reftex-toc-quit)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5876 (define-key map "Q" 'reftex-toc-quit-and-kill)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5877 (define-key map "f" 'reftex-toc-toggle-follow)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5878 (define-key map "x" 'reftex-toc-external)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5879 (loop for key across "0123456789" do
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5880 (define-key map (vector (list key)) 'digit-argument))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5881 (define-key map "-" 'negative-argument))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5882
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5883 ;;; Menus --------------------------------------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5884
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5885 ;; 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
5886
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5887 (require 'easymenu)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5888
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5889 (easy-menu-define
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5890 reftex-mode-menu reftex-mode-map
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5891 "Menu used in RefTeX mode"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5892 `("Ref"
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
5893 ["Table of Contents" reftex-toc t]
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5894 "----"
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
5895 ["\\label" reftex-label t]
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
5896 ["\\ref" reftex-reference t]
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
5897 ["\\cite" reftex-citation t]
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5898 ["View Crossref" reftex-view-crossref t]
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5899 "----"
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5900 ("Parse Document"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5901 ["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
5902 ["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
5903 ["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
5904 (> (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
5905 ["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
5906 "----"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5907 ["Enable Partial Scans"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5908 (setq reftex-enable-partial-scans (not reftex-enable-partial-scans))
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5909 :style toggle :selected reftex-enable-partial-scans]
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5910 ["Auto-Save Parse Info"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5911 (setq reftex-save-parse-info (not reftex-save-parse-info))
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5912 :style toggle :selected reftex-save-parse-info]
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5913 "---"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5914 ["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
5915 ("Global Actions"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5916 ["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
5917 ["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
5918 ["Grep on Document" reftex-grep-document t]
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5919 "----"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5920 ["Create TAGS File" reftex-create-tags-file t]
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5921 "----"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5922 ["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
5923 ["Change Label and Refs" reftex-change-label t]
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5924 ;;;["Renumber Simple Labels" reftex-renumber-simple-labels t]
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5925 "---"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5926 ["Save document" reftex-save-all-document-buffers t])
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5927 "---"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5928 ("Reference Options"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5929 "Varioref Setting"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5930 ["Use `\\vref' by Default"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5931 (setq reftex-vref-is-default (not reftex-vref-is-default))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5932 :style toggle :selected reftex-vref-is-default]
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5933 "---"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5934 "Selection Buffers"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5935 ["Use Multiple Buffers"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5936 (setq reftex-use-multiple-selection-buffers
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5937 (not reftex-use-multiple-selection-buffers))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5938 :style toggle :selected reftex-use-multiple-selection-buffers]
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5939 ["Auto Update Buffers"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5940 (setq reftex-auto-update-selection-buffers
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5941 (not reftex-auto-update-selection-buffers))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5942 :style toggle :selected reftex-auto-update-selection-buffers])
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5943 ("Citation Options"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5944 "Citation Style"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5945 ,@(mapcar
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5946 (function
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5947 (lambda (x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5948 (vector
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5949 (capitalize (symbol-name (car x)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5950 (list 'setq 'reftex-cite-format (list 'quote (car x)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5951 ':style 'radio ':selected
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5952 (list 'eq 'reftex-cite-format (list 'quote (car x))))))
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5953 reftex-cite-format-builtin)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5954 "----"
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5955 "Bibinfo in Comments"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5956 ["Attach Comments"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5957 (setq reftex-comment-citations (not reftex-comment-citations))
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5958 :style toggle :selected reftex-comment-citations]
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5959 "---"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5960 "Sort Database Matches"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5961 ["by Author" (setq reftex-sort-bibtex-matches 'author)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5962 :style radio :selected (eq reftex-sort-bibtex-matches 'author)]
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5963 ["by Year" (setq reftex-sort-bibtex-matches 'year)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5964 :style radio :selected (eq reftex-sort-bibtex-matches 'year)]
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5965 ["by Year, reversed" (setq reftex-sort-bibtex-matches 'reverse-year)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5966 :style radio :selected (eq reftex-sort-bibtex-matches 'reverse-year)]
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5967 ["Not" (setq reftex-sort-bibtex-matches nil)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5968 :style radio :selected (eq reftex-sort-bibtex-matches nil)])
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5969 ("Customize"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5970 ["Browse RefTeX group" reftex-customize t]
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5971 "---"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5972 ["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
5973 (fboundp 'customize-menu-create)])
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5974 "----"
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5975 ("Documentation"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5976 ["Info" reftex-info t]
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5977 ["Commentary" reftex-show-commentary t])))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5978
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5979 ;;; Run Hook ------------------------------------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5980
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5981 (run-hooks 'reftex-load-hook)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5982
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5983 ;;; That's it! ----------------------------------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5984
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
5985 (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
5986 (provide 'reftex)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5987
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5988 ;;;============================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5989
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
5990 ;;; reftex.el ends here