annotate lisp/textmodes/reftex.el @ 21114:3e8ab19bdccb

1998-03-08 Carsten Dominik <cd@gnu.org> * (reftex-cursor-selected-face, reftex-mouse-selected-face, reftex-file-boundary-face, reftex-label-face, reftex-section-heading-face, reftex-toc-header-face, reftex-bib-author-face, reftex-bib-year-face, reftex-bib-title-face, reftex-bib-extra-face): New options. (reftex-toc, reftex-make-and-insert-label-list, reftex-format-bib-entry, reftex-section-info): Use fonts defined in the new options. (reftex-do-citation): Kill buffer *RefTeX Select* to avoid problems with lazy-lock.
author Carsten Dominik <dominik@science.uva.nl>
date Sun, 08 Mar 1998 11:40:12 +0000
parents 0c95fb73e090
children fea2f6a2818d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
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
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
734 :type 'function)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
735
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
736 ;; Label referencing
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
737
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
738 (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
739 "Options on how to reference labels."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
740 :group 'reftex-label-support)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
741
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
742 (eval-and-compile
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
743 (defconst reftex-tmp
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
744 '((const :tag "on" t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
745 (const :tag "off" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
746 (string :tag "Selected label types"))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
747
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
748 (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
749 "List of flags governing the label menu makeup.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
750 The flags are:
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
751
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
752 TABLE-OF-CONTENTS Show the labels embedded in a table of context.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
753 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
754 COUNTERS Show counters. This just numbers the labels in the menu.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
755 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
756 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
757 SHOW-COMMENTED Show labels from regions which are commented out.
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
758 MATCH-IN-TOC Searches in label menu will also match in toc lines.
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
759 SHOW FILES Show begin and end of included files.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
760
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
761 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
762 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
763 like character classes in regular expressions. Thus, setting one of the
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
764 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
765 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
766 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
767 e (equation), n (footnote), plus any definitions in `reftex-label-alist'.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
768
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
769 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
770 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
771 get one interactively during selection from the label menu."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
772 :group 'reftex-referencing-labels
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
773 :type
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
774 `(list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
775 (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
776 (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
777 (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
778 (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
779 (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
780 (choice :tag "Show commented labels " ,@reftex-tmp)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
781 (choice :tag "Searches match in toc lines " ,@reftex-tmp)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
782 (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
783
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
784 (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
785 "*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
786 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
787 `\\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
788 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
789 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
790 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
791 :group 'reftex-referencing-labels
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
792 :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
793
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
794 (defcustom reftex-level-indent 2
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
795 "*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
796 :group 'reftex-referencing-labels
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
797 :type '(integer))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
798
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
799 (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
800 "*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
801 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
802 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
803 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
804 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
805 :group 'reftex-referencing-labels
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
806 :type '(boolean))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
807
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
808 (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
809 "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
810 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
811 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
812 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
813 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
814 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
815 :group 'reftex-referencing-labels
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
816 :type 'function)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
817
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
818 ;; BibteX citation configuration ----------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
819
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
820 (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
821 "Support for referencing bibliographic data with BibTeX."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
822 :group 'reftex)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
823
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
824 (defcustom reftex-bibpath-environment-variables '("BIBINPUTS" "TEXBIB")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
825 "*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
826 :group 'reftex-citation-support
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
827 :set 'reftex-set-dirty
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
828 :type '(repeat (string :tag "Environment variable")))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
829
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
830 (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
831 "*List of files in \\bibliography{..} RefTeX should *not* parse.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
832 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
833 macro - i.e. without the `.bib' extension.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
834 Intended for files which contain only `@string' macro definitions and the
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
835 like, which are ignored by RefTeX anyway."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
836 :group 'reftex-citation-support
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
837 :set 'reftex-set-dirty
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
838 :type '(repeat (string :tag "File name")))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
839
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
840 (defcustom reftex-default-bibliography nil
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
841 "*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
842 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
843 `\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
844 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
845 `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
846 :group 'reftex-citation-support
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
847 :type '(repeat (file)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
848
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
849 (defcustom reftex-sort-bibtex-matches 'reverse-year
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
850 "*Sorting of the entries found in BibTeX databases by reftex-citation.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
851 Possible values:
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
852 nil Do not sort entries.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
853 'author Sort entries by author name.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
854 'year Sort entries by increasing year.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
855 'reverse-year Sort entries by decreasing year."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
856 :group 'reftex-citation-support
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
857 :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
858 (const :tag "by author" author)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
859 (const :tag "by year" year)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
860 (const :tag "by year, reversed" reverse-year)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
861
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
862 (defcustom reftex-cite-format 'default
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
863 "*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
864 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
865 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
866 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
867
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
868 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
869 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
870
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
871 %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
872 %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
873 %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
874 %A First author name only.
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
875 %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
876
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
877 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
878 %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
879 %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
880 %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
881 %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
882 %v volume %y year
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
883
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
884 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
885
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
886 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
887 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
888 environment, only %l is available.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
889
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
890 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
891 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
892 strings.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
893 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
894 `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
895 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
896 (setq reftex-cite-format 'harvard)"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
897 :group 'reftex-citation-support
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
898 :type
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
899 `(choice
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
900 :format "%{%t%}: \n%[Value Menu%] %v"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
901 (radio :tag "Symbolic Builtins"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
902 :indent 4
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
903 :value default
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
904 ,@(mapcar
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
905 (function
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
906 (lambda (x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
907 (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
908 ": " (nth 1 x))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
909 (nth 0 x))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
910 reftex-cite-format-builtin))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
911 (string :tag "format string" "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
912 (repeat :tag "key-ed format strings"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
913 :value ((?\r . "\\cite{%l}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
914 (?t . "\\cite{%l}") (?p . "\\cite{%l}"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
915 (cons (character :tag "Key character" ?\r)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
916 (string :tag "Format string" "")))))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
917
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
918 (defcustom reftex-comment-citations nil
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
919 "*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
920 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
921 :group 'reftex-citation-support
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
922 :type '(boolean))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
923
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
924 (defcustom reftex-cite-comment-format
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
925 "%% %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
926 "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
927 :group 'reftex-citation-support
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
928 :type '(string))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
929
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
930 (defcustom reftex-cite-punctuation '(", " " \\& " " {\\it et al.}")
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
931 "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
932 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
933 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
934 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
935 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
936 :group 'reftex-citation-support
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
937 :type '(list
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
938 (string :tag "Separator for names ")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
939 (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
940 (string :tag "string used as et al. ")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
941
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
942 (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
943 "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
944 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
945 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
946 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
947 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
948 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
949 :group 'reftex-citation-support
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
950 :type 'function)
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
951
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
952 ;; Table of contents configuration --------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
953
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
954 (defgroup reftex-table-of-contents-browser nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
955 "A multifile table of contents browser."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
956 :group 'reftex)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
957
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
958 (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
959 "*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
960 The other window will show the corresponding part of the document.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
961 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
962 :group 'reftex-table-of-contents-browser
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
963 :type '(boolean))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
964
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
965 ;; Tuning the parser ----------------------------------------------------
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
966
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
967 (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
968 "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
969 :group 'reftex)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
970
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
971 (defcustom reftex-keep-temporary-buffers 1
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
972 "*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
973 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
974 We distinguish files visited for
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
975 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
976 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
977 to display label context, etc.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
978 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
979 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
980
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
981 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
982 t Keep everything.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
983 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
984 for lookup.
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 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
987 slow but will happen only once).
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
988 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
989 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
990 :group 'reftex-miscellaneous-configurations
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
991 :type '(choice
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
992 (const :tag "Throw away everything" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
993 (const :tag "Keep everything" t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
994 (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
995
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
996 (defcustom reftex-initialize-temporary-buffers nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
997 "*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
998 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
999 visit a file.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1000 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
1001 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
1002 do a minimal initialization."
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1003 :group 'reftex-miscellaneous-configurations
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1004 :type '(choice
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1005 (const :tag "Read files literally" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1006 (const :tag "Fully initialize buffers" t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1007 (repeat :tag "Hook functions" :value (nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1008 (function-item))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1009
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1010 (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
1011 "*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
1012 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
1013 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
1014 :group 'reftex-optimizations-for-large-documents
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1015 :type '(repeat (regexp)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1016
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1017 (defcustom reftex-enable-partial-scans nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1018 "*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
1019 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
1020 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
1021 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
1022 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
1023 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
1024 in menus."
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1025 :group 'reftex-optimizations-for-large-documents
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1026 :type 'boolean)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1027
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1028 (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
1029 "*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
1030 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
1031 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
1032 list."
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1033 :group 'reftex-optimizations-for-large-documents
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1034 :type 'boolean)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1035
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1036 (defcustom reftex-save-parse-info nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1037 "*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
1038 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
1039 information. When this variable is t,
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1040 - 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
1041 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
1042 - 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
1043 is written."
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1044 :group 'reftex-optimizations-for-large-documents
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1045 :type 'boolean)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1046
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1047 (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
1048 "*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
1049 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
1050 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
1051 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
1052 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
1053 `reftex-auto-update-selection-buffers'."
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1054 :group 'reftex-optimizations-for-large-documents
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1055 :type 'boolean)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1056
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1057 (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
1058 "*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
1059 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
1060 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
1061 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
1062 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
1063 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
1064 `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
1065 :group 'reftex-optimizations-for-large-documents
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1066 :type 'boolean)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1067
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1068 ;; Fontification and Faces ----------------------------------------------
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1069
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1070 (defgroup reftex-fontification-configurations nil
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1071 "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
1072 :group 'reftex)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1073
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1074 (defcustom reftex-use-fonts t
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1075 "*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
1076 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
1077 :group 'reftex-fontification-configurations
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1078 :type '(boolean))
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1079
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1080 (defcustom reftex-refontify-context 1
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1081 "*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
1082 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
1083 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
1084
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1085 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
1086 nil Never refontify.
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1087 t Always refontify.
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1088 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
1089 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
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 '(choice
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1092 (const :tag "Never" nil)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1093 (const :tag "Always" t)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1094 (const :tag "When necessary" 1)))
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1095
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1096 (defcustom reftex-highlight-selection 'cursor
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1097 "*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
1098 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
1099 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
1100 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
1101 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
1102 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
1103
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1104 nil No highlighting.
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1105 cursor Highlighting is cursor driven.
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1106 mouse Highlighting is mouse driven.
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1107 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
1108 :group 'reftex-fontification-configurations
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1109 :type '(choice
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1110 (const :tag "Never" nil)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1111 (const :tag "Cursor driven" cursor)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1112 (const :tag "Mouse driven" mouse)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1113 (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
1114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1115 (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
1116 "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
1117 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
1118 :group 'reftex-fontification-configurations
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1119 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1120 (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
1121 "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
1122 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
1123 :group 'reftex-fontification-configurations
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1124 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1125 (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
1126 "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
1127 :group 'reftex-fontification-configurations
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1128 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1129 (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
1130 "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
1131 :group 'reftex-fontification-configurations
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1132 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1133 (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
1134 "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
1135 :group 'reftex-fontification-configurations
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1136 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1137 (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
1138 "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
1139 :group 'reftex-fontification-configurations
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1140 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1141 (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
1142 "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
1143 :group 'reftex-fontification-configurations
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1144 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1145 (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
1146 "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
1147 :group 'reftex-fontification-configurations
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1148 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1149 (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
1150 "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
1151 :group 'reftex-fontification-configurations
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1152 :type 'symbol)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1153 (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
1154 "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
1155 :group 'reftex-fontification-configurations
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
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1158 ;; Miscellaneous configurations -----------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1159
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1160 (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
1161 "Collection of further configurations."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1162 :group 'reftex)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1163
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1164 (defcustom reftex-extra-bindings nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1165 "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
1166 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
1167 :group 'reftex-miscellaneous-configurations
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1168 :type '(boolean))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1169
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1170 (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
1171 "*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
1172 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
1173 means:
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1174
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1175 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
1176 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
1177 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
1178 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
1179
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1180 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
1181 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
1182 \\<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
1183 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
1184 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
1185 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
1186 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
1187 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
1188 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
1189 :group 'reftex-miscellaneous-configurations
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1190 :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
1191 (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
1192 (list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1193 :tag "Individual choice"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1194 :value (nil nil nil nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1195 (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
1196 (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
1197 (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
1198 (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
1199 )))
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1200
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1201 (defcustom reftex-auto-show-entry 'copy
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1202 "*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
1203 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
1204 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
1205 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
1206 context to a temporary buffer (value 'copy)."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1207 :group 'reftex-miscellaneous-configurations
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1208 :type '(radio :value copy
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1209 :indent 4
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1210 (const :tag "Do nothing" nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1211 (const :tag "Unhide section permanently" t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1212 (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
1213
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1214 (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
1215 "*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
1216 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
1217 :group 'reftex-miscellaneous-configurations
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1218 :type '(boolean))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1219
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1220 (defcustom reftex-load-hook nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1221 "Hook which is being run when loading reftex.el."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1222 :group 'reftex-miscellaneous-configurations
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1223 :type 'hook)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1224
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1225 (defcustom reftex-mode-hook nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1226 "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
1227 :group 'reftex-miscellaneous-configurations
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1228 :type 'hook)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1229
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1230 ;;; End of Configuration Section ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1231
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1232 ;;;===========================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1233 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1234 ;;; Define the formal stuff for a minor mode named RefTeX.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1235 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1236
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
1237 ;; This file corresponds to RefTeX version 3.21
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
1238
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1239 (defvar reftex-mode nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1240 "Determines if RefTeX minor mode is active.")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1241 (make-variable-buffer-local 'reftex-mode)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1242
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1243 (defvar reftex-mode-map (make-sparse-keymap)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1244 "Keymap for RefTeX minor mode.")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1245
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1246 (defvar reftex-mode-menu nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1247
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1248 ;;;###autoload
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1249 (defun turn-on-reftex ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1250 "Turn on RefTeX minor mode."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1251 (reftex-mode t))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1252
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1253 ;;;###autoload
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1254 (defun reftex-mode (&optional arg)
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
1255 "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
1256
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1257 Labels can be created with `\\[reftex-label]' and referenced with `\\[reftex-reference]'.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1258 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
1259 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
1260 \\ref macro.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1261
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1262 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
1263 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
1264 database. The selected citation is inserted as a \\cite macro.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1265
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1266 A Table of Contents of the entire (multifile) document with browsing
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1267 capabilities is available with `\\[reftex-toc]'.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1268
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1269 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
1270 pressing `?' to any prompt mentioning this feature.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1271
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1272 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
1273 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
1274
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1275 \\{reftex-mode-map}
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1276 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
1277 on the menu bar.
18050
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 ------------------------------------------------------------------------------"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1280
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1281 (interactive "P")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1282 (setq reftex-mode (not (or (and (null arg) reftex-mode)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1283 (<= (prefix-numeric-value arg) 0))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1284
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1285 ; Add or remove the menu, and run the hook
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1286 (if reftex-mode
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1287 (progn
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1288 (easy-menu-add reftex-mode-menu)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1289 (reftex-plug-into-AUCTeX)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1290 (run-hooks 'reftex-mode-hook))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1291 (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
1292
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1293 (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
1294 (push '(reftex-mode " Ref") minor-mode-alist))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1295
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1296 (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
1297 (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
1298
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1299 ;;; ===========================================================================
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1300 ;;;
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1301 ;;; 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
1302 (defvar TeX-master)
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1303 (defvar LaTeX-label-function)
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1304 (defvar tex-main-file)
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1305 (defvar outline-minor-mode)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1306 (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
1307 (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
1308
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1309 ;;; ===========================================================================
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 ;;; Interfaces for other packages
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1312 ;;; -----------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1313 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1314 ;;; AUCTeX
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1315 ;;; ------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1316
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1317 (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
1318 "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
1319 This function is intended for AUCTeX macro support."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1320 (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
1321 (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
1322 (LaTeX-add-labels label))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1323 (TeX-argument-insert label optional optional)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1324
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1325 (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
1326 "Use `reftex-reference' to select label. Insert with `TeX-argument-insert'.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1327 This function is intended for AUCTeX macro support."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1328 (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
1329 (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
1330 (LaTeX-add-labels label))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1331 (TeX-argument-insert label optional optional)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1332
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1333 (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
1334 "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
1335 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
1336 (let ((key (reftex-citation t)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1337 (TeX-argument-insert (or key "") optional optional)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1338
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1339 (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
1340 ;; 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
1341 ;; 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
1342 ;; `reftex-plug-into-AUCTeX'.
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1343 (let ((flags
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1344 (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
1345 ((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
1346 (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
1347
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1348 (and (nth 0 flags)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1349 (boundp 'LaTeX-label-function)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1350 (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
1351
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1352 (and (nth 1 flags)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1353 (fboundp 'TeX-arg-label)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1354 (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
1355
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1356 (and (nth 2 flags)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1357 (fboundp 'TeX-arg-ref)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1358 (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
1359
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1360 (and (nth 3 flags)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1361 (fboundp 'TeX-arg-cite)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1362 (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
1363
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1364
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1365 (defvar reftex-label-alist-external-add-ons nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1366 "List of label alist entries added with reftex-add-to-label-alist.")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1367
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1368 (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
1369 "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
1370 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
1371 for details.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1372 This function makes it possible to support RefTeX from AUCTeX style files.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1373 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
1374 `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
1375 `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
1376 `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
1377 mode reset is done on the next occasion."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1378 (let (entry)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1379 (while entry-list
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1380 (setq entry (car entry-list)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1381 entry-list (cdr entry-list))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1382 (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
1383 (setq reftex-tables-dirty t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1384 (push entry reftex-label-alist-external-add-ons)))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1385
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1386 ;;; ===========================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1387 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1388 ;;; Multifile support
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1389 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1390 ;;; Technical notes: Multifile works as follows: We keep just one list
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1391 ;;; 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
1392 ;;; `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
1393 ;;; 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
1394 ;;; document. Each buffer has local variables which point to these symbols.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1395
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1396 ;; List of variables which handle the multifile stuff.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1397 ;; This list is used to tie, untie, and reset these symbols.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1398 (defconst reftex-multifile-symbols
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1399 '(reftex-docstruct-symbol))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1400
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1401 ;; Alist connecting master file names with the corresponding lisp symbols.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1402 (defvar reftex-master-index-list nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1403
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1404 ;; Last index used for a master file.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1405 (defvar reftex-multifile-index 0)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1406
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1407 ;; 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
1408 (defvar reftex-docstruct-symbol nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1409 (make-variable-buffer-local 'reftex-docstruct-symbol)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1410
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1411 (defun reftex-next-multifile-index ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1412 ;; 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
1413 (incf reftex-multifile-index))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1414
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1415 (defun reftex-tie-multifile-symbols ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1416 ;; Tie the buffer-local symbols to globals connected with the master file.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1417 ;; 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
1418
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1419 (let* ((master (file-truename (reftex-TeX-master-file)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1420 (index (assoc master reftex-master-index-list))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1421 (symlist reftex-multifile-symbols)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1422 (symbol nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1423 (symname nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1424 (newflag nil))
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1425 ;; Find the correct index.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1426 (if index
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1427 ;; symbols do exist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1428 (setq index (cdr index))
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1429 ;; Get a new index and add info to the alist.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1430 (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
1431 newflag t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1432 (push (cons master index) reftex-master-index-list))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1433
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1434 ;; Get/create symbols and tie them.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1435 (while symlist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1436 (setq symbol (car symlist)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1437 symlist (cdr symlist)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1438 symname (symbol-name symbol))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1439 (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
1440 (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
1441 ;; Initialize if new symbols.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1442 (if newflag (set (symbol-value symbol) nil)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1443
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1444 ;; 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
1445 (not newflag)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1446
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1447 (defun reftex-untie-multifile-symbols ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1448 ;; Remove ties from multifile symbols, so that next use makes new ones.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1449 (let ((symlist reftex-multifile-symbols)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1450 (symbol nil))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1451 (while symlist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1452 (setq symbol (car symlist)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1453 symlist (cdr symlist))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1454 (set symbol nil))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1455
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1456 (defun reftex-TeX-master-file ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1457 ;; Return the name of the master file associated with the current buffer.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1458 ;; 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
1459 ;; 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
1460 ;; variable tex-main-file.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1461 (let
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1462 ((master
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1463 (cond
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1464 ((fboundp 'TeX-master-file) ; AUCTeX is loaded. Use its mechanism.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1465 (TeX-master-file t))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1466 ((boundp 'TeX-master) ; The variable is defined - lets use it.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1467 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1468 ((eq TeX-master t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1469 (buffer-file-name))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1470 ((eq TeX-master 'shared)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1471 (setq TeX-master (read-file-name "Master file: "
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1472 nil nil t nil)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1473 (TeX-master)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1474 (t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1475 (setq TeX-master (read-file-name "Master file: "
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1476 nil nil t nil)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1477 ((boundp 'tex-main-file)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1478 ;; This is the variable from the default TeX modes.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1479 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1480 ((stringp tex-main-file)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1481 ;; ok, this must be it
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1482 tex-main-file)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1483 (t
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1484 ;; In this case, the buffer is its own master.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1485 (buffer-file-name))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1486 (t
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1487 ;; Know nothing about master file. Assume this is a master file.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1488 (buffer-file-name)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1489 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1490 ((null master)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1491 (error "Need a filename for this buffer. Please save it first."))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1492 ((or (file-exists-p master)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1493 (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
1494 ;; 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
1495 )
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1496 ((or (file-exists-p (concat master ".tex"))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1497 (reftex-get-buffer-visiting (concat master ".tex")))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1498 ;; Ahh, an extra .tex was missing...
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1499 (setq master (concat master ".tex")))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1500 (t
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1501 ;; 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
1502 (buffer-file-name)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1503 ; (error "No such master file %s" master)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1504 (expand-file-name master)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1505
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1506 (defun reftex-parse-one ()
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1507 "Re-parse this file."
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1508 (interactive)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1509 (let ((reftex-enable-partial-scans t))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1510 (reftex-access-scan-info '(4))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1511
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1512 (defun reftex-parse-all ()
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1513 "Re-parse entire document."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1514 (interactive)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1515 (reftex-access-scan-info '(16)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1516
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1517 (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
1518 ;; 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
1519 ;; 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
1520 ;; of master file.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1521 (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
1522 (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
1523 (re (concat "\\`" (regexp-quote master-dir)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1524 file-list tmp file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1525 (while (setq tmp (assoc 'bof all))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1526 (setq file (nth 1 tmp)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1527 all (cdr (memq tmp all)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1528 (and relative
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1529 (string-match re file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1530 (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
1531 (push file file-list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1532 (nreverse file-list)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1533
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1534 (defun reftex-create-tags-file ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1535 "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
1536 The TAGS file is also immediately visited with `visit-tags-table'."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1537 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1538 (reftex-access-scan-info current-prefix-arg)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1539 (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
1540 (files (reftex-all-document-files))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1541 (cmd (format "etags %s" (mapconcat 'identity files " "))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1542 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1543 (set-buffer (reftex-get-buffer-visiting master))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1544 (message "Running etags to create TAGS file...")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1545 (shell-command cmd)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1546 (visit-tags-table "TAGS"))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1547
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1548 ;; History of grep commands.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1549 (defvar reftex-grep-history nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1550 (defvar reftex-grep-command "grep -n "
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1551 "Last grep command used in \\[reftex-grep-document]; default for next grep.")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1552
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1553 (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
1554 "Run grep query through all files related to this document.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1555 With prefix arg, force to rescan document.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1556 This works also without an active TAGS table."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1557
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1558 (interactive
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1559 (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
1560 reftex-grep-command nil nil
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1561 'reftex-grep-history)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1562 (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
1563 (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
1564 (cmd (format
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1565 "%s %s" grep-cmd
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1566 (mapconcat 'identity files " "))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1567 (grep cmd)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1568
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1569 (defun reftex-search-document (&optional regexp)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1570 "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
1571 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
1572 To continue searching for next match, use command \\[tags-loop-continue].
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1573 This works also without an active TAGS table."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1574 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1575 (let ((default (reftex-this-word)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1576 (unless regexp
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1577 (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
1578 default))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1579 (if (string= regexp "") (setq regexp (regexp-quote default)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1580
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1581 (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
1582 (tags-search regexp (list 'reftex-all-document-files))))
18050
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 (defun reftex-query-replace-document (&optional from to delimited)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1585 "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
1586 Third arg DELIMITED (prefix arg) means replace only word-delimited matches.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1587 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
1588 with the command \\[tags-loop-continue].
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1589 This works also without an active TAGS table."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1590 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1591 (let ((default (reftex-this-word)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1592 (unless from
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1593 (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
1594 default)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1595 (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
1596 (unless to
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1597 (setq to (read-string (format "Replace regexp %s with: " from))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1598 (reftex-access-scan-info current-prefix-arg)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1599 (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
1600 (list 'reftex-all-document-files))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1601
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1602 (defun reftex-change-label (&optional from to)
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
1603 "Query replace FROM with TO in all \\label and \\ref commands.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1604 Works on the entire multifile document.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1605 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
1606 with the command \\[tags-loop-continue].
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1607 This works also without an active TAGS table."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1608 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1609 (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
1610 (unless from
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1611 (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
1612 default))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1613 (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
1614 (unless to
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1615 (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
1616 from))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1617 (reftex-query-replace-document
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1618 (concat "\\\\\\(label\\|[a-z]*ref\\){" (regexp-quote from) "}")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1619 (format "\\\\\\1{%s}" to))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1620
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1621 (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
1622 "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
1623 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
1624 labels."
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1625 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1626 (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
1627 file buffer)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1628 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1629 (while (setq file (pop files))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1630 (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
1631 (when buffer
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1632 (set-buffer buffer)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1633 (save-buffer))))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1634
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1635 ;;; ===========================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1636 ;;;
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1637 ;;; 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
1638
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1639 ;; 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
1640
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1641 ;; Prompt used for label type queries directed to the user.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1642 (defconst reftex-type-query-prompt nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1643
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1644 ;; Help string for label type queries.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1645 (defconst reftex-type-query-help nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1646
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1647 ;; Alist relating label type to reference format.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1648 (defconst reftex-typekey-to-format-alist nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1649
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1650 ;; Alist relating label type to label affix.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1651 (defconst reftex-typekey-to-prefix-alist nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1652
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1653 ;; Alist relating environments or macros to label type and context regexp.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1654 (defconst reftex-env-or-mac-alist nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1655
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1656 ;; List of macros carrying a label.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1657 (defconst reftex-label-mac-list nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1658
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1659 ;; List of environments carrying a label.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1660 (defconst reftex-label-env-list nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1661
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1662 ;; List of all typekey letters in use.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1663 (defconst reftex-typekey-list nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1664
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1665 ;; Alist relating magic words to a label type.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1666 (defconst reftex-words-to-typekey-alist nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1667
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1668 ;; The last list-of-labels entry used in a reference.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1669 (defvar reftex-last-used-reference (list nil nil nil nil))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1670
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1671 ;; The regular expression used to abbreviate words.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1672 (defconst reftex-abbrev-regexp
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1673 (concat
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1674 "\\`\\("
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1675 (make-string (nth 0 reftex-abbrev-parameters) ?.)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1676 "[" (nth 2 reftex-abbrev-parameters) "]*"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1677 "\\)"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1678 "[" (nth 3 reftex-abbrev-parameters) "]"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1679 (make-string (1- (nth 1 reftex-abbrev-parameters)) ?.)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1680
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1681 ;; Global variables used for communication between functions.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1682 (defvar reftex-default-context-position nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1683 (defvar reftex-location-start nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1684 (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
1685 (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
1686 (defvar reftex-active-toc nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1687 (defvar reftex-tex-path nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1688 (defvar reftex-bib-path nil)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
1689 (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
1690 (defvar reftex-prefix)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1691
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
1692 ;; List of buffers created temporarily for lookup, which should be killed.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1693 (defvar reftex-buffers-to-kill nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1694
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
1695 ;; 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
1696 (defvar reftex-section-regexp nil)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1697 (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
1698 (defvar reftex-everything-regexp nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1699 (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
1700 (defvar reftex-find-label-regexp-format2 nil)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1701
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1702 ;; The parser functions ----------------------------------
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1703
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1704 (defvar reftex-memory nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1705 "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
1706
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1707 (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
1708 ;; 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
1709 ;; 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
1710 ;; 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
1711
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1712 ;; 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
1713 (when (or reftex-tables-dirty
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1714 (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
1715 (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
1716 (nth 1 reftex-memory)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1717 (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
1718 (nth 2 reftex-memory))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1719 (reftex-reset-mode))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1720
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1721 (if (eq reftex-docstruct-symbol nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1722 ;; 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
1723 (reftex-tie-multifile-symbols))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1724
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1725 (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
1726 (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
1727 ;; 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
1728 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1729 (reftex-erase-all-selection-buffers)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1730
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1731 (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
1732 reftex-save-parse-info)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1733 ;; 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
1734 (reftex-access-parse-file 'read))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1735
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1736 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1737 ((not (symbol-value reftex-docstruct-symbol))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1738 (reftex-do-parse 1 file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1739 ((member rescan '(t 1 (4) (16)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1740 (reftex-do-parse rescan file))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1741
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1742 (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
1743 ;; 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
1744
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1745 ;; Normalize the rescan argument
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1746 (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
1747 ((eq rescan 1) 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1748 ((equal rescan '(4)) t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1749 ((equal rescan '(16)) 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1750 (t 1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1751
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1752 ;; Partial scans only when allowed
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1753 (unless reftex-enable-partial-scans
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1754 (setq rescan 1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1755
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1756 ;; Do the scanning.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1757
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1758 (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
1759 (master (reftex-TeX-master-file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1760 (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
1761 (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
1762 from-file appendix docstruct tmp)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1763
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1764 ;; 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
1765 (when (and (eq rescan t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1766 (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
1767 (member (list 'eof file) old-list))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1768 (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
1769 (setq rescan 1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1770 (when (string= file master)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1771 (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
1772 (setq rescan 1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1773
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1774 ;; From which file do we start?
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1775 (setq from-file
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1776 (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
1777 ((eq rescan 1) master)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1778 (t (error "horrible!!"))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1779
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1780 ;; 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
1781 (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
1782 '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
1783 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
1784 '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
1785
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1786 (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
1787
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1788 (if (eq rescan 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1789 (message "Scanning entire document...")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1790 (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
1791
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1792 (save-window-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1793 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1794 (unwind-protect
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1795 (setq docstruct
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1796 (reftex-parse-from-file
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1797 from-file docstruct master-dir))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1798 (reftex-kill-temporary-buffers))))
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 (message "Scanning document... done")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1801
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1802 ;; Turn the list around.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1803 (setq docstruct (nreverse docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1804
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1805 ;; Set or insert
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1806 (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
1807 old-list docstruct (eq rescan 1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1808
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1809 ;; Add all missing information
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1810 (unless (assq 'label-numbers docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1811 (push (cons 'label-numbers nil) docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1812 (unless (assq 'master-dir docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1813 (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
1814 (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
1815 (bof2 (assq 'bof (cdr bof1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1816 (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
1817 (entry (or (assq 'is-multi docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1818 (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
1819 (setcdr entry (cons is-multi nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1820 (unless (assq 'xr docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1821 (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
1822 (alist (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1823 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1824 (lambda (x)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1825 (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
1826 master-dir))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1827 (cons (nth 1 x) tmp)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1828 (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
1829 (nth 2 x))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1830 nil)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1831 allxr))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1832 (alist (delete nil alist))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1833 (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
1834 (regexp (if allprefix
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1835 (concat "\\`\\("
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1836 (mapconcat 'identity allprefix "\\|")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1837 "\\)")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1838 "\\\\\\\\\\\\"))) ; this will never match
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1839 (push (list 'xr alist regexp) docstruct)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1840
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1841 (set reftex-docstruct-symbol docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1842
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1843 ;; 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
1844 (if reftex-save-parse-info
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1845 (reftex-access-parse-file 'write))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1846
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1847 (defun reftex-is-multi ()
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1848 ;; 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
1849 (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
1850 (if entry
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1851 (nth 1 entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1852 t)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1853
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1854 (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
1855 ;; 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
1856 (let ((regexp reftex-everything-regexp)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1857 (bound 0)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1858 file-found tmp include-file
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1859 (level 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1860 (highest-level 100)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1861 toc-entry next-buf)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1862
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1863 (catch 'exit
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1864 (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
1865 (unless file-found
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1866 (push (list 'file-error file) docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1867 (throw 'exit nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1868
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1869 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1870
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1871 (message "Scanning file %s" file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1872 (set-buffer
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1873 (setq next-buf
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1874 (reftex-get-file-buffer-force
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1875 file-found
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1876 (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
1877
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1878 ;; Begin of file mark
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1879 (setq file (buffer-file-name))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1880 (push (list 'bof file) docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1881
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1882 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1883 (save-restriction
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1884 (widen)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1885 (goto-char 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1886
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1887 (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
1888
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1889 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1890
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1891 ((match-end 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1892 ;; It is a label
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1893 (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
1894 docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1895
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1896 ((match-end 3)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1897 ;; It is a section
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1898 (setq bound (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1899
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1900 ;; Insert in List
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1901 (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
1902 (setq level (nth 5 toc-entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1903 (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
1904 (if (= level highest-level)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1905 (message
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1906 "Scanning %s %s ..."
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1907 (car (nth level reftex-section-levels))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1908 (nth 6 toc-entry)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1909
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1910 (push toc-entry docstruct)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1911 (setq reftex-active-toc toc-entry))
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 ((match-end 7)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1914 ;; 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
1915 (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
1916 (if (delq nil (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1917 (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
1918 reftex-no-include-regexps))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1919 (progn
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1920 ;; Ignore the file
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1921 (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
1922 (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
1923 ;; Parse it
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1924 (setq docstruct
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1925 (reftex-parse-from-file
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1926 include-file
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1927 docstruct master-dir))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1928
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1929 ((match-end 9)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1930 ;; Appendix starts here
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1931 (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
1932 (push (cons 'appendix t) docstruct))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1933
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1934 ((match-end 10)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1935 ;; A macro with label
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1936 (save-excursion
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1937 (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
1938 (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
1939 (save-match-data
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1940 (reftex-no-props
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1941 (reftex-nth-arg-wrapper
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1942 mac)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1943 (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
1944 (reftex-label-info
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1945 label file bound mac))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1946 (push entry docstruct))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1947 (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
1948 )
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1949
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1950
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1951 ;; Find bibliography statement
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1952 (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
1953 (push (cons 'bib tmp) docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1954
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1955 (goto-char 1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1956 (when (re-search-forward
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1957 "\\(\\`\\|[\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
1958 (push (cons 'thebib file) docstruct))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1959
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1960 ;; Find external document specifications
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1961 (goto-char 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1962 (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
1963 (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
1964 (reftex-match-string 3))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1965 docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1966
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1967 ;; End of file mark
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1968 (push (list 'eof file) docstruct))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1969
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1970 ;; Kill the scanned buffer
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1971 (reftex-kill-temporary-buffers next-buf))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1972
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1973 ;; Return the list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1974 docstruct))
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 (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
1977 ;; 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
1978 (let (file-list)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1979 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1980 (goto-char (point-min))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1981 (if (re-search-forward
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1982 "\\(\\`\\|[\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
1983 (setq file-list
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1984 (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
1985 (reftex-delete-list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1986 reftex-bibfile-ignore-list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1987 (split-string
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1988 (reftex-match-string 2)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1989 "[ \t\n\r]*,[ \t\n\r]*")))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1990 (delete nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1991 (mapcar
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1992 (function
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1993 (lambda (file)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
1994 (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
1995 file-list)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1996
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
1997 (defun reftex-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
1998 ;; 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
1999 ;; 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
2000 ;; 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
2001 ;; On success, returns the association.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2002 (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
2003
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2004 (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
2005 (setq list (memq ass list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2006 (memq elt list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2007 (setq last-ass ass
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2008 list (cdr list)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2009 last-ass))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2010
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2011 (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
2012 ;; 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
2013 ;; 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
2014 ;; 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
2015 ;; 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
2016
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2017 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2018 (entirely
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2019 (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
2020 insert)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2021 (t (let* ((new old)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2022 (file (nth 1 (car insert)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2023 (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
2024 (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
2025 n)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2026 (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
2027 (error "Cannot splice")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2028 ;; Splice
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2029 (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
2030 (length eof-list)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2031 (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
2032 (setcdr (nthcdr n new) (cdr insert))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2033 (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
2034 new))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2035
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2036 (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
2037 ;; 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
2038 (while (and list (> (decf n) -1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2039 (and (eq (car (car list)) 'toc)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2040 (markerp (nth 4 (car list)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2041 (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
2042 (pop list)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2043
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2044 (defun reftex-access-parse-file (action)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2045 (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
2046 (master (reftex-TeX-master-file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2047 (enable-local-variables nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2048 (file (if (string-match "\\.[a-zA-Z]+\\'" master)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2049 (concat (substring master 0 (match-beginning 0)) ".rel")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2050 (concat master ".rel"))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2051 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2052 ((eq action 'readable)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2053 (file-readable-p file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2054 ((eq action 'restore)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2055 (if (eq reftex-docstruct-symbol nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2056 ;; 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
2057 (reftex-tie-multifile-symbols))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2058 (if (file-exists-p file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2059 ;; 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
2060 (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
2061 ;; throw an exception
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2062 (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
2063 ((eq action 'read)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2064 (if (file-exists-p file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2065 ;; 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
2066 (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
2067 ;; 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
2068 nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2069 (t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2070 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2071 (if (file-writable-p file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2072 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2073 (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
2074 (find-file file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2075 (erase-buffer)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2076 (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
2077 (insert (format ";; File: %s\n" master))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2078 (insert (format ";; Date: %s\n"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2079 (format-time-string "%D %T"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2080 (current-time))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2081 (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
2082 (user-login-name) (user-full-name)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2083 (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
2084 (let ((standard-output (current-buffer)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2085 (mapcar
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2086 (function
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2087 (lambda (x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2088 (cond ((eq (car x) 'toc)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2089 ;; 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
2090 ;; 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
2091 (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
2092 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
2093 (or (and (markerp (nth 4 x))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2094 (marker-position (nth 4 x)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2095 (nth 8 x)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2096 (t (print x)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2097 list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2098 (insert "))")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2099 (save-buffer 0)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2100 (kill-buffer (current-buffer)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2101 (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
2102 t))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2103
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2104 ;; Creating labels --------------
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2105
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2106 (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
2107 "Insert a unique label. Return the label.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2108 If ENVIRONMENT is given, don't bother to find out yourself.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2109 If NO-INSERT is non-nil, do not insert label into buffer.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2110 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
2111 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
2112 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
2113 A new label is also recorded into the label list.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2114 This function is controlled by the settings of reftex-insert-label-flags."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2115
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2116 (interactive)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2117
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
2118 ;; 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
2119 (reftex-access-scan-info current-prefix-arg)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2120
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
2121 ;; 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
2122 (if (or (not environment)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2123 (not (assoc environment reftex-env-or-mac-alist)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2124 (setq environment (reftex-label-location)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2125 (unless environment
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2126 (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
2127
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
2128 ;; Ok, go ahead.
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2129 (catch 'exit
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2130 (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
2131 (typekey (nth 1 entry))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2132 (format (nth 3 entry))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2133 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
2134 (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
2135 (nth 5 entry)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2136 (memq (preceding-char) '(?\[ ?\{)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2137 (setq format "%s"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2138
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2139 (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
2140 (concat typekey "-")))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2141 ;; 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
2142 (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
2143
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2144 ;; Make a default label.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2145 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2146
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2147 ((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
2148 ;; Derive a label from context.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2149 (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
2150 '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
2151 (symbol-value reftex-docstruct-symbol)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2152 (setq default (reftex-no-props
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2153 (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
2154 ;; 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
2155 (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
2156 (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
2157 (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
2158 (string-match "HOOK ERROR" default)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2159 (string-match "^[ \t]*$" default))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2160 (setq default prefix
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2161 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
2162 (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
2163
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2164 ;; Make it unique.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2165 (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
2166
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2167 ((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
2168 ;; 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
2169 (setq default prefix))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2170
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2171 (t
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2172 ;; Make an automatic label.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2173 (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
2174
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2175 ;; Should we ask the user?
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2176 (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
2177 (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
2178 force-prompt)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2179
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2180 (while (not valid)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2181 ;; 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
2182
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2183 (setq label (read-string
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2184 (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
2185 default))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2186
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2187 ;; 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
2188 (cond
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 ((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
2191 "\\)?[ \t]*\\'")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2192 label)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2193 ;; No label at all, please
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2194 (message "No label inserted.")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2195 (throw 'exit nil))
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 ;; 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
2198 ((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
2199 (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
2200 (ding)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2201 (sit-for 2))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2202
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2203 ;; 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
2204 ((setq entry (assoc label
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2205 (symbol-value reftex-docstruct-symbol)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2206 (ding)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2207 (if (y-or-n-p
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2208 (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
2209 (setq valid t)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2210
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2211 ;; Label is ok
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2212 (t
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2213 (setq valid t))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2214 (setq label default))
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 ;; 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
2217 (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
2218 (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
2219 (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
2220 ""
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2221 "POSITION UNCERTAIN. RESCAN TO FIX."))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2222 (file (buffer-file-name))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2223 (text nil)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2224 (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
2225
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2226 (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
2227
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2228 (if tail
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2229 (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
2230 (cdr tail)))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2231
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2232 ;; 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
2233 (unless no-insert
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2234 (insert
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2235 (if reftex-format-label-function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2236 (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
2237 (format format label))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2238
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2239 ;; 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
2240 (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
2241 (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
2242 (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
2243
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2244 (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
2245 (reftex-parse-one))
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 ;; 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
2248 label)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2249
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2250 (defun reftex-string-to-label (string)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2251 ;; Convert a string (a sentence) to a label.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2252 ;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2253 ;; Uses reftex-derive-label-parameters and reftex-abbrev-parameters
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2254 ;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2255
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2256 (let* ((words0 (split-string string "[- \t\n\r]+"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2257 (ignore-words (nth 5 reftex-derive-label-parameters))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2258 words word)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2259
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2260 ;; 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
2261 (while (setq word (pop words0))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2262 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2263 ((member (downcase word) ignore-words))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2264 ((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
2265 (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
2266 (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
2267 (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
2268 (push word words)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2269 (t
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2270 (push word words))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2271 (setq words (nreverse words))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2272
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2273 ;; restrict number of words
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2274 (if (> (length words) (nth 0 reftex-derive-label-parameters))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2275 (setcdr (nthcdr (1- (nth 0 reftex-derive-label-parameters)) words) nil))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2276
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2277 ;; 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
2278 (setq string (mapconcat 'identity words
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2279 (nth 4 reftex-derive-label-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 ;; Abbreviate words if enforced by user settings or string length
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2282 (if (or (eq t (nth 3 reftex-derive-label-parameters))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2283 (and (nth 3 reftex-derive-label-parameters)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2284 (> (length string) (nth 1 reftex-derive-label-parameters))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2285 (setq words
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2286 (mapcar
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2287 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2288 (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
2289 (match-string 1 w)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2290 w)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2291 words)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2292 string (mapconcat 'identity words
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2293 (nth 4 reftex-derive-label-parameters))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2294
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2295 ;; Shorten if still to long
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2296 (setq string
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2297 (if (> (length string) (nth 1 reftex-derive-label-parameters))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2298 (substring string 0 (nth 1 reftex-derive-label-parameters))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2299 string))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2300
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2301 ;; 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
2302 (if (string-match "[^a-zA-Z0-9]+\\'" string)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2303 (setq string (replace-match "" nil nil string)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2304 string))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2305
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2306 (defun reftex-replace-prefix-escapes (prefix)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2307 ;; Replace %escapes in a label prefix
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2308 (save-match-data
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2309 (let (letter (num 0) replace)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2310 (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
2311 (setq letter (match-string 1 prefix))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2312 (setq replace
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2313 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2314 ((equal letter "f")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2315 (file-name-sans-extension
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2316 (file-name-nondirectory (buffer-file-name))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2317 ((equal letter "F")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2318 (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
2319 (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
2320 (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
2321 file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2322 (substring file (length masterdir))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2323 file)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2324 ((equal letter "u")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2325 (or (user-login-name) ""))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2326 (t "")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2327 (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
2328 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
2329 prefix)))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2330
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2331 (defun reftex-label-location (&optional bound)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2332 ;; Return the environment or macro which determines the label type at point.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2333 ;; If optional BOUND is an integer, limit backward searches to that point.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2334
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2335 (let* ((loc1 (reftex-what-macro reftex-label-mac-list bound))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2336 (loc2 (reftex-what-environment reftex-label-env-list bound))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2337 (p1 (or (cdr loc1) 0))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2338 (p2 (or (cdr loc2) 0)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2339
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2340 (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
2341 (if (>= p1 p2)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2342 (progn
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2343 (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
2344 (or (car loc1) "section"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2345 (setq reftex-default-context-position (+ p2 8 (length (car loc2))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2346 (or (car loc2) "section"))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2347
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2348 (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
2349 ;; 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
2350 ;; 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
2351 ;; Optional SEPARATOR is a string to stick between label and number.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2352
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2353 ;; Ensure access to scanning info
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2354 (reftex-access-scan-info)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2355
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2356 (cond
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2357 ((and (not force)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2358 (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
2359 label)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2360 (t
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2361 (let* ((label-numbers (assq 'label-numbers
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2362 (symbol-value reftex-docstruct-symbol)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2363 (label-numbers-alist (cdr label-numbers))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2364 (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
2365 (car (setcdr label-numbers
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2366 (cons (cons label 0)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2367 label-numbers-alist)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2368 (num (1+ (cdr cell)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2369 (sep (or separator "")))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2370 (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
2371 (symbol-value reftex-docstruct-symbol))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2372 (incf num))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2373 (setcdr cell num)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2374 (concat label sep (int-to-string num))))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2375
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2376 ;; 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
2377 (defconst reftex-select-label-prompt
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2378 "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
2379
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2380 (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
2381 " 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
2382 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
2383 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
2384 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
2385 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
2386 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
2387 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
2388 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
2389 [#] 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
2390 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
2391 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
2392 TAB Enter a label with completion
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2393 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
2394
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2395 (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
2396 "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
2397 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
2398 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
2399
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2400 (defun reftex-select-label-mode ()
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2401 "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
2402 This buffer was created with RefTeX.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2403 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
2404 selection process.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2405 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
2406 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
2407
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2408 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
2409
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2410 \\{reftex-select-label-map}"
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2411
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2412 (interactive)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2413 (kill-all-local-variables)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2414 (make-local-hook 'pre-command-hook)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2415 (make-local-hook 'post-command-hook)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2416 (setq major-mode 'reftex-select-label-mode
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2417 mode-name "RefTeX Select Label")
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2418 ;; 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
2419 (run-hooks 'reftex-select-label-mode-hook))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2420
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2421 (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
2422 "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
2423 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
2424 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
2425 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
2426 label selection menu.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2427 The function returns the selected label or nil.
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
2428 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
2429 When called with 2 C-u prefix args, disable magic word recognition."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2430
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2431 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2432
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2433 ;; check for active recursive edits
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2434 (reftex-check-recursive-edit)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2435
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2436 ;; 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
2437 (reftex-access-scan-info current-prefix-arg)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2438
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2439 (unless type
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2440 ;; guess type from context
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2441 (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
2442 (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
2443 (setq cut (cdr type)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2444 type (car type))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2445 (setq type (reftex-query-label-type))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2446
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2447 (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
2448 type reftex-vref-is-default)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2449 "\\vref" "\\ref"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2450 (form "\\ref{%s}")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2451 label pair)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2452
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2453 ;; Have the user select a label
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2454 (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
2455 (setq pair (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2456 (reftex-offer-label-menu type)))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2457 (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
2458 (setq label (car pair)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2459 type (cdr pair)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2460 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
2461 form))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2462
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2463 (if (and label
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2464 (not no-insert))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2465 (progn
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2466 (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
2467
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2468 ;; 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
2469 (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
2470 (= ?\ (preceding-char)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2471 (setq form (substring form 1)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2472 ;; 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
2473 (when (string= varioref "\\vref")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2474 (while (string-match "\\\\ref{" form)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2475 (setq form (replace-match "\\vref{" t t form))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2476 ;; ok, insert the reference
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2477 (insert
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2478 (if reftex-format-ref-function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2479 (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
2480 (format form label label)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2481 (message ""))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2482 (message "Quit"))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2483 ;; return the label
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2484 label))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2485
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2486 (defun reftex-guess-label-type ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2487 (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
2488 (case-fold-search t)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2489 (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
2490 matched cell)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2491 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2492 (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
2493 (not (setq matched
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2494 (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
2495 (if matched
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2496 (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
2497 nil)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2498
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2499 (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
2500 ;; Offer a menu with the appropriate labels. Return (label . typekey).
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2501 (let* ((buf (current-buffer))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2502 (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
2503 (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
2504 (xr-index 0)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2505 (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
2506 (here-I-am1 here-I-am)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2507 (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
2508 (files (reftex-typekey-check typekey reftex-label-menu-flags 7))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2509 (context (not (reftex-typekey-check
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2510 typekey reftex-label-menu-flags 3)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2511 (counter (reftex-typekey-check
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2512 typekey reftex-label-menu-flags 2))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2513 (follow (reftex-typekey-check
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2514 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
2515 (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
2516 (match-everywhere (reftex-typekey-check
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2517 typekey reftex-label-menu-flags 6))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2518 (prefix "")
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2519 selection-buffers
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2520 offset rtn key data last-data entry)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2521
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2522 (setq entry (cons nil nil))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2523
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2524 ;; The following unwind-protect kills temporary buffers after use
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2525 (unwind-protect
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2526 (catch 'exit
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2527 (while t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2528 (save-window-excursion
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2529 (delete-other-windows)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2530 (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
2531 (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
2532 (if reftex-use-multiple-selection-buffers
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2533 (switch-to-buffer-other-window
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2534 (save-excursion
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2535 (set-buffer buf)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2536 (reftex-make-selection-buffer-name typekey)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2537 (switch-to-buffer-other-window "*RefTeX Select*")
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2538 (reftex-erase-buffer)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2539 (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
2540 (reftex-select-label-mode))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2541 (add-to-list 'selection-buffers (current-buffer))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2542 (setq truncate-lines t)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2543 (setq mode-line-format
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2544 (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
2545 " " 'varioref
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2546 " " (abbreviate-file-name
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2547 (buffer-file-name buf))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2548 " -%-"))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2549 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2550 ((= 0 (buffer-size))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2551 (let ((buffer-read-only nil))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2552 (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
2553 typekey buf toc files context counter commented
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2554 (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
2555 (here-I-am
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2556 (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
2557 (t (setq offset t)))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2558 (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
2559 (setq offset (or offset t))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2560
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2561 (setq here-I-am nil) ; turn off determination of offset
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2562 (setq rtn
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2563 (reftex-select-item
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2564 reftex-select-label-prompt
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2565 reftex-select-label-help
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2566 reftex-select-label-map
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2567 offset
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2568 'reftex-select-label-callback follow
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2569 match-everywhere))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2570 (setq key (car rtn)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2571 data (nth 1 rtn)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2572 last-data (nth 2 rtn)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2573 offset t)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2574 (unless key (throw 'exit nil))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2575 (cond
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2576 ((eq key ?g)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2577 ;; update buffer
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2578 (reftex-erase-buffer))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2579 ((or (eq key ?r)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2580 (eq key ?R))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2581 ;; rescan buffer
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2582 (reftex-erase-buffer)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2583 (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
2584 ((eq key ?c)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2585 ;; toggle context mode
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2586 (reftex-erase-buffer)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2587 (setq context (not context)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2588 ((eq key ?s)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2589 ;; switch type
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2590 (setq here-I-am here-I-am1)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2591 (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
2592 ((eq key ?t)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2593 ;; toggle table of contents display
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2594 (reftex-erase-buffer)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2595 (setq toc (not toc)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2596 ((eq key ?i)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2597 ;; toggle display of included file borders
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2598 (reftex-erase-buffer)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2599 (setq files (not files)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2600 ((eq key ?#)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2601 ;; toggle counter display
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2602 (reftex-erase-buffer)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2603 (setq counter (not counter)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2604 ((eq key ?%)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2605 ;; toggle display of commented labels
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2606 (reftex-erase-buffer)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2607 (setq commented (not commented)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2608 ((eq key ?l)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2609 ;; reuse the last referenced label again
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2610 (setq entry reftex-last-used-reference)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2611 (throw 'exit t))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2612 ((eq key ?x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2613 ;; select an external document
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2614 (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
2615 xr-alist xr-index))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2616 (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
2617 (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
2618 (error "Cannot switch document"))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2619 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
2620 (set-buffer buf)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2621 (reftex-access-scan-info))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2622 ((stringp key)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2623 (setq entry
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2624 (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
2625 (list key typekey)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2626 (throw 'exit t))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2627 (t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2628 (set-buffer buf)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2629 (if data
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2630 (progn
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2631 (setq entry data)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2632 (setq reftex-last-used-reference entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2633 (setq entry nil))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2634 (throw 'exit t))))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2635 (mapcar (function (lambda (buf)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2636 (and (buffer-live-p buf)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2637 (bury-buffer buf))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2638 selection-buffers)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2639 (reftex-kill-buffer "*RefTeX Context Copy*")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2640 (reftex-kill-temporary-buffers))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2641 (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
2642 (nth 1 entry))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2643
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2644 (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
2645 ;; 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
2646 (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
2647 (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
2648 key prefix)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2649 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2650 ((= len 1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2651 (message "No external documents available")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2652 (ding) 0)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2653 ((= len 2)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2654 (- 1 xr-index))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2655 (t
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2656 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2657 (save-window-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2658 (let* ((length (apply 'max (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2659 (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
2660 (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
2661 (n (1- ?0)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2662 (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
2663 (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
2664 (princ
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2665 (mapconcat
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2666 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2667 (lambda (x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2668 (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
2669 (abbreviate-file-name (cdr x)))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2670 xr-alist ""))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2671 (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
2672 (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
2673 (setq truncate-lines t)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2674 (catch 'exit
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2675 (while t
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2676 (princ prompt)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2677 (setq key (read-char-exclusive))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2678 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2679 ((= 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
2680 ((= 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
2681 ((and (>= key ?0) (<= key highest))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2682 (throw 'exit (- key ?0)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2683 ((= key ?\C-i)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2684 (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
2685 (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
2686 xr-alist)))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2687 (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
2688
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2689 (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
2690 ;; 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
2691 (format "*RefTeX[%s][%d]*"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2692 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
2693
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2694 (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
2695 ;; 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
2696 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2697 (set-buffer buf)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2698 (reftex-access-scan-info)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2699 (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
2700 entry)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2701 (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
2702 (not (and (stringp (car entry))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2703 (equal typekey (nth 1 entry))))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2704 entry)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2705
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2706 (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
2707 (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
2708 ;; 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
2709 ;; 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
2710 (let* ((font (reftex-use-fonts))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2711 (cnt 0)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2712 (index -1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2713 (toc-indent " ")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2714 (label-indent
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2715 (concat "> "
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2716 (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
2717 (context-indent
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2718 (concat ". "
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2719 (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
2720 (mouse-face
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
2721 (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
2722 reftex-mouse-selected-face
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
2723 nil))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2724 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
2725 offset from to docstruct-symbol)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2726
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2727 (message "Creating Selection Buffer...")
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2728
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2729 ;; Pop to buffer buf to get the correct buffer-local variables
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2730 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2731 (set-buffer buf)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2732
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2733 ;; Ensure access to scanning info
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2734 (reftex-access-scan-info)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2735
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2736 (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
2737 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
2738 reftex-active-toc nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2739 master-dir-re
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2740 (concat "\\`" (regexp-quote
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2741 (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
2742
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2743 (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
2744 (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
2745 (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
2746 (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
2747
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2748 ;; 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
2749 (while (setq cell (pop all))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2750
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2751 (incf index)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2752 (setq from (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2753
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2754 (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
2755
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2756 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2757
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2758 ((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
2759 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
2760 ;; These are currently ignored
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2761
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2762 ((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
2763 ;; Beginning or end of a file
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2764 (when files
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2765 (insert
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2766 " 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
2767 (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
2768 (nth 1 cell))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2769 (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
2770 ((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
2771 ((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
2772 (when font
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2773 (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
2774 'face reftex-file-boundary-face))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2775
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2776 ((eq (car cell) 'toc)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2777 ;; a table of contents entry
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2778 (when toc
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2779 (setq reftex-active-toc cell)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2780 (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
2781
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2782 ((stringp (car cell))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2783 ;; a label
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2784 (when (null (nth 2 cell))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2785 ;; 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
2786 (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
2787
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2788 (setq label (car cell)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2789 typekey (nth 1 cell)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2790 text (nth 2 cell)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2791 note (nth 4 cell)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2792 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
2793
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2794 (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
2795 (or show-commented (null comment)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2796
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2797 ;; Yes we want this one
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2798 (incf cnt)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2799 (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
2800
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2801 (setq label (concat xr-prefix label))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2802 (when comment (setq label (concat "% " label)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2803 (insert label-indent label)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2804 (when font
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2805 (put-text-property
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2806 (- (point) (length label)) (point)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2807 'face (if comment
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2808 'font-lock-comment-face
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
2809 reftex-label-face)))
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 (insert (if counter (format " (%d) " cnt) "")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2812 (if comment " LABEL IS COMMENTED OUT " "")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2813 (if note (concat " " note) "")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2814 "\n")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2815 (setq to (point))
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 context
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2818 (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
2819 (setq to (point)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2820 (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
2821 (when mouse-face
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2822 (put-text-property from (1- to)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
2823 'mouse-face mouse-face))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2824 (goto-char to)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2825
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2826 (when (reftex-refontify)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2827 (reftex-fontify-select-label-buffer))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2828 offset))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
2830 (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
2831 "Rescan the document."
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2832 (interactive)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2833 (save-window-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2834 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2835 (if buffer
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2836 (if (not (bufferp buffer))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2837 (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
2838 (set-buffer buffer)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2839 (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
2840 (file (nth 3 data)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2841 (reftex-access-scan-info arg file)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2842
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2843 (defun reftex-query-label-type ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2844 ;; Ask for label type
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2845 (message reftex-type-query-prompt)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2846 (let ((key (read-char)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2847 (when (eq key ?\?)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2848 (save-window-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2849 (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
2850 (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
2851 (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
2852 (setq key (read-char))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2853 (kill-buffer "*RefTeX Help*")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2854 (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
2855 (error "No such label type: %s" (char-to-string key)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2856 (char-to-string key)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2857
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2858 ;; Variable holding the vector with section numbers
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2859 (defvar reftex-section-numbers [0 0 0 0 0 0 0 0])
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2860
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2861 (defun reftex-section-info (file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2862 ;; 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
2863 ;; 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
2864 (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
2865 (macro (reftex-match-string 3))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2866 (star (= ?* (char-after (match-end 3))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2867 (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
2868 (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
2869 (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
2870 (literal (buffer-substring-no-properties
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2871 (1- (match-beginning 3))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2872 (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
2873 ;; 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
2874 (text (reftex-nicify-text text1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2875
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2876 ;; Add section number and indentation
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2877 (setq text
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2878 (concat
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2879 (make-string (* reftex-level-indent level) ?\ )
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2880 (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
2881 (concat section-number " "))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2882 text))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2883 ;; Fontify
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2884 (if (reftex-use-fonts)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2885 (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
2886 '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
2887 (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
2888 literal (marker-position marker))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2889
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2890 (defun reftex-label-info-update (cell)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2891 ;; Update information about just one label in a different file.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2892 ;; CELL contains the old info list
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2893 (let* ((label (nth 0 cell))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2894 (typekey (nth 1 cell))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2895 ;; (text (nth 2 cell))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2896 (file (nth 3 cell))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2897 (note (nth 4 cell))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2898 (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
2899 file (not (eq t reftex-keep-temporary-buffers)))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2900 (if (not buf)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
2901 (list label typekey "" file "LOST LABEL. RESCAN TO FIX.")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2902 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2903 (set-buffer buf)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2904 (save-restriction
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2905 (widen)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2906 (goto-char 1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2907
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2908 (if (or (re-search-forward
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2909 (format reftex-find-label-regexp-format
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2910 (regexp-quote label)) nil t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2911 (re-search-forward
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2912 (format reftex-find-label-regexp-format2
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2913 (regexp-quote label)) nil t))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2914
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2915 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2916 (backward-char 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2917 (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
2918 (list label typekey "" file "LOST LABEL. RESCAN TO FIX.")))))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2919
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2920 (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
2921 ;; 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
2922 (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
2923 (typekey (nth 1 (assoc env-or-mac reftex-env-or-mac-alist)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2924 (file (or file (buffer-file-name)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2925 (parse (if (reftex-typekey-check
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2926 typekey reftex-use-text-after-label-as-context)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2927 nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2928 (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
2929 (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
2930 derive)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2931 (if (reftex-in-comment)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2932 (put-text-property 0 1 'in-comment t text))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2933 (list label typekey text file)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2934
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2935 (defun reftex-in-comment ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2936 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2937 (skip-chars-backward "^%\n\r")
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2938 (eq (preceding-char) ?%)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2939
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2940 (defun reftex-short-context (env parse &optional bound derive)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2941 ;; 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
2942
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2943 (if (consp parse)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2944 (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
2945
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2946 (reftex-nicify-text
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2947
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2948 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2949
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2950 ((null parse)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2951 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2952 (reftex-context-substring)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2953
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2954 ((eq parse t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2955 (if (string= env "section")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2956 ;; special treatment for section labels
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2957 (save-excursion
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2958 (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
2959 (point-min) t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2960 (match-end 2))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2961 (progn
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2962 (goto-char (match-end 0))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2963 (reftex-context-substring))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2964 (if reftex-active-toc
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2965 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2966 (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
2967 (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
2968 "SECTION HEADING NOT FOUND")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2969 (save-excursion
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2970 (goto-char reftex-default-context-position)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2971 (unless (eq (string-to-char env) ?\\)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2972 (reftex-move-over-touching-args))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2973 (reftex-context-substring))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2974
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2975 ((stringp parse)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2976 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2977 (if (re-search-backward parse bound t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2978 (progn
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2979 (goto-char (match-end 0))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2980 (reftex-context-substring))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2981 "NO MATCH FOR CONTEXT REGEXP")))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2982
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2983 ((integerp parse)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2984 (or (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2985 (goto-char reftex-default-context-position)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2986 (reftex-nth-arg
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2987 parse
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
2988 (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
2989 ""))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2990
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2991 ((fboundp parse)
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
2992 ;; A hook function. Call it.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2993 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2994 (condition-case error-var
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2995 (funcall parse env)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
2996 (error (format "HOOK ERROR: %s" (cdr error-var))))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2997 (t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2998 "ILLEGAL VALUE OF PARSE"))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2999
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3000 (defun reftex-where-am-I ()
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3001 ;; 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
3002 ;; 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
3003 ;; exact (t) or approximate (nil).
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3004
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3005 (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
3006 (cnt 0) rtn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3007 found)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3008 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3009 (while (not rtn)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3010 (incf cnt)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3011 (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
3012 (setq rtn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3013 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3014 ((not found)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3015 ;; no match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3016 (or
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3017 (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
3018 (not (setq cnt 2))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3019 (assq 'bof docstruct) ;; for safety reasons
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3020 'corrupted))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3021 ((match-end 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3022 ;; Label
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3023 (assoc (reftex-match-string 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3024 (symbol-value reftex-docstruct-symbol)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3025 ((match-end 3)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3026 ;; Section
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3027 (goto-char (1- (match-beginning 3)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3028 (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
3029 docstruct))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3030 (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
3031 list)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3032 rtn1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3033 (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
3034 (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
3035 (string= (buffer-file-name)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3036 (nth 3 (car list))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3037 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3038 ((equal (point)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3039 (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
3040 (marker-position (nth 4 (car list))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3041 (nth 8 (car list))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3042 ;; 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
3043 (setq rtn1 (car list) list nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3044 ((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
3045 (nth 7 (car list))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3046 ;; Same title
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3047 (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
3048 (pop list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3049 rtn1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3050 ((match-end 7)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3051 ;; Input or include...
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3052 (car
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3053 (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
3054 (reftex-match-string 7)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3055 (cdr (assq 'master-dir docstruct))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3056 docstruct)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3057 ((match-end 9)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3058 (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
3059 ((match-end 10)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3060 (save-excursion
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3061 (goto-char (match-end 10))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3062 (assoc (reftex-no-props
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3063 (reftex-nth-arg-wrapper
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3064 (reftex-match-string 10)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3065 (symbol-value reftex-docstruct-symbol))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3066 (t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3067 (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
3068 (cons rtn (eq cnt 1))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3069
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3070 (defun reftex-parse-args (macro)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3071 ;; 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
3072 ;; optional argument indices.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3073 (if (string-match "[[{]\\*?[]}]" macro)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3074 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3075 (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
3076 (args (substring macro (match-beginning 0)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3077 opt-list nlabel (cnt 0))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3078 (while (string-match "\\`[[{]\\(\\*\\)?[]}]" args)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3079 (incf cnt)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3080 (when (eq ?\[ (string-to-char args))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3081 (push cnt opt-list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3082 (when (and (match-end 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3083 (not nlabel))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3084 (setq nlabel cnt))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3085 (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
3086 (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
3087 nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3088
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3089 (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
3090 ;; 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
3091 ;; 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
3092 ;; 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
3093 ;; in TeX.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3094 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3095 ;; Just to be quick:
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3096 ((memq (following-char) '(?\[ ?\{)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3097 ;; Do a search
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3098 ((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
3099 (goto-char (1- (match-end 0)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3100 t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3101 (t nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3103 (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
3104 ;; 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
3105 ;; 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
3106 ;; 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
3107 ;; in TeX.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3108 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3109 ;; Just to be quick:
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3110 ((memq (preceding-char) '(?\] ?\})))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3111 ;; Do a search
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3112 ((re-search-backward
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3113 "[]}][ \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
3114 (goto-char (1+ (match-beginning 0)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3115 t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3116 (t nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3117
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3118 (defun reftex-nth-arg-wrapper (key)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3119 (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
3120 (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
3121
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3122 (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
3123 ;; 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
3124 ;; 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
3125
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3126 ;; 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
3127 (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
3128
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3129 (if (= n 1000)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3130 ;; Special case: Skip all touching arguments
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3131 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3132 (reftex-move-over-touching-args)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3133 (reftex-context-substring))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3134
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3135 ;; Do the real thing.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3136 (let ((cnt 1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3137
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3138 (when (reftex-move-to-next-arg)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3139
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3140 (while (< cnt n)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3141 (while (and (member cnt opt-args)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3142 (eq (following-char) ?\{))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3143 (incf cnt))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3144 (when (< cnt n)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3145 (unless (and (condition-case nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3146 (or (forward-list 1) t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3147 (error nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3148 (reftex-move-to-next-arg)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3149 (incf cnt))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3150 (setq cnt 1000))))
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 (while (and (memq cnt opt-args)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3153 (eq (following-char) ?\{))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3154 (incf cnt)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3155 (if (and (= n cnt)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3156 (> (skip-chars-forward "{\\[") 0))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3157 (reftex-context-substring)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3158 nil))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3159
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3160 (defun reftex-move-over-touching-args ()
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3161 (condition-case nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3162 (while (memq (following-char) '(?\[ ?\{))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3163 (forward-list 1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3164 (error nil)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3165
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3166 (defun reftex-context-substring ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3167 ;; Return up to 100 chars from point
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3168 ;; When point is just after a { or [, limit string to matching parenthesis
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3169 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3170 ((or (= (preceding-char) ?\{)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3171 (= (preceding-char) ?\[))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3172 ;; 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
3173 (buffer-substring-no-properties
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3174 (point)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3175 (min (reftex-fp 150)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3176 (point-max)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3177 (condition-case nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3178 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3179 (up-list 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3180 (1- (point)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3181 (error (point-max))))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3182 (t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3183 ;; 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
3184 (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
3185
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3186 (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
3187 ;; 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
3188 ;; in the toc entry.
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3189 (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
3190 (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
3191 (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
3192 (i depth) number-string)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3193 (while (>= i 0)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3194 (if (> i level)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3195 (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
3196 (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
3197 (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
3198 (aset reftex-section-numbers i
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3199 (- (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
3200 (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
3201 (pop numbers))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3202 (decf i)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3203 (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
3204
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3205 (defun reftex-section-number (&optional level star)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3206 ;; Return a string with the current section number.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3207 ;; 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
3208 (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
3209 (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
3210 (when level
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3211 (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
3212 (aset reftex-section-numbers
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3213 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
3214 (setq idx (1+ level))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3215 (while (<= idx depth)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3216 (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
3217 (incf idx)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3218 (setq idx 0)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3219 (while (<= idx depth)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3220 (setq n (aref reftex-section-numbers idx))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3221 (setq string (concat string (if (not (string= string "")) "." "")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3222 (int-to-string n)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3223 (incf idx))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3224 (save-match-data
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3225 (if (string-match "\\`\\([@0]\\.\\)+" string)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3226 (setq string (replace-match "" nil nil string)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3227 (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
3228 (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
3229 (if (and appendix
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3230 (string-match "\\`[0-9]+" string))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3231 (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
3232
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3233 (if star
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3234 (concat (make-string (1- (length string)) ?\ ) "*")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3235 string)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3236
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3237 (defun reftex-select-label-callback (data forward no-revisit)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3238 ;; Callback function called from the label selection in order to
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3239 ;; show context in another window
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3240 (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
3241 label file buffer re found)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3242 ;; pop to original buffer in order to get correct variables
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3243 (catch 'exit
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3244 (setq label (nth 0 data)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3245 file (nth 3 data))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3246
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3247 ;; 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
3248 (setq buffer
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3249 (if no-revisit
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3250 (get-file-buffer file)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3251 (reftex-get-file-buffer-force
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3252 file (not reftex-keep-temporary-buffers))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3253 (if buffer
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3254 ;; good - the file is available
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3255 (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
3256 ;; we have got a problem here. The file does not exist.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3257 ;; 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
3258 ;; (ding)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3259 (throw 'exit nil))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3260
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3261 ;; search for that label
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3262 (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
3263 (setq found
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3264 (if forward
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3265 (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
3266 (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
3267 (unless found
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3268 (goto-char (point-min))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3269 (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
3270 ;; 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
3271 (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
3272 (regexp-quote label)) nil t)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3273 (when (match-end 3)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3274 (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
3275 (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
3276 (- (point) (match-end 3)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3277 (recenter (/ (window-height) 2)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3278 (select-window this-window))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3279
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3280 (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
3281 ;; Find LABEL in any file in FILE-LIST in another window.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3282 ;; If mark-to-kill is non-nil, mark new buffer for killing.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3283 ;; 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
3284 (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
3285 (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
3286 (re-list (list re1 re2)) re
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3287 (file-list-1 file-list)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3288 file buf)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3289 (catch 'exit
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3290 (while (setq re (pop re-list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3291 (setq file-list file-list-1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3292 (while (setq file (pop file-list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3293 (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
3294 (error "No such file %s" file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3295 (set-buffer buf)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3296 (widen)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3297 (goto-char (point-min))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3298 (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
3299 (switch-to-buffer-other-window buf)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3300 (goto-char (match-beginning 0))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3301 (recenter (/ (window-height) 2))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3302 (if highlight
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3303 (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
3304 (throw 'exit (selected-window)))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3305 (error "Label %s not found" label))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3306
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3307 (defun reftex-find-duplicate-labels ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3308 "Produce a list of all duplicate labels in the document."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3309
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3310 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3311
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3312 ;; Rescan the document to make sure
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3313 (reftex-access-scan-info t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3314
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3315 (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
3316 (cnt 0)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3317 (dlist
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3318 (mapcar
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3319 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3320 (lambda (x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3321 (let (x1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3322 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3323 ((memq (car x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3324 '(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
3325 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
3326 nil)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3327 (t
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3328 (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
3329 (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
3330 (if (< 1 (length x1))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3331 (append (list (car x))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3332 (mapcar (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3333 (lambda(x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3334 (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
3335 x1))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3336 (list nil)))))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3337 (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
3338
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3339 (setq dlist (reftex-uniquify dlist))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3340 (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
3341 (switch-to-buffer-other-window "*Duplicate Labels*")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3342 (make-local-variable 'TeX-master)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3343 (setq TeX-master master)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3344 (erase-buffer)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3345 (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
3346 (insert
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
3347 " 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
3348 " and its references. Type `q' to exit this buffer.\n\n")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3349 (insert " LABEL FILE\n")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3350 (insert " -------------------------------------------------------------\n")
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
3351 (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
3352 (local-set-key [?q] (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3353 (lambda () (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3354 (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
3355 (local-set-key [?r] 'reftex-change-label)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3356 (while dlist
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3357 (when (and (car (car dlist))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3358 (cdr (car dlist)))
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
3359 (incf cnt)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3360 (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
3361 (pop dlist))
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
3362 (goto-char (point-min))
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
3363 (when (= cnt 0)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
3364 (kill-buffer (current-buffer))
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
3365 (delete-window)
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
3366 (message "Document does not contain duplicate labels."))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3367
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3368 (defun reftex-all-assq (key list)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3369 ;; 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
3370 (let (rtn)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3371 (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
3372 (push (car list) rtn)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3373 (pop list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3374 (nreverse rtn)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3375
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3376 (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
3377 ;; 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
3378 (let (rtn)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3379 (while list
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3380 (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
3381 (push (car list) rtn))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3382 (pop list))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3383 (nreverse rtn)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3384
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3385 (defun reftex-kill-temporary-buffers (&optional buffer)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3386 ;; 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
3387 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3388 (buffer
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3389 (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
3390 (kill-buffer buffer)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3391 (setq reftex-buffers-to-kill
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3392 (delete buffer reftex-buffers-to-kill))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3393 (t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3394 (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
3395 (when (bufferp buffer)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3396 (and (buffer-modified-p buffer)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3397 (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
3398 (buffer-file-name buffer)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3399 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3400 (set-buffer buffer)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3401 (save-buffer)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3402 (kill-buffer buffer))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3403 (pop reftex-buffers-to-kill)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3404
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3405 (defun reftex-show-entry (beg-hlt end-hlt)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3406 ;; 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
3407 (let* ((pos (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3408 (n (/ (window-height) 2))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3409 (beg (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3410 (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
3411 (end (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3412 (re-search-forward "[\n\r]" nil 1 n) (point))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3413 (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
3414 (string-match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3415 "\r" (buffer-substring beg end)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3416 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3417 ((eq t reftex-auto-show-entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3418 (subst-char-in-region
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3419 (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
3420 (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
3421 ?\r ?\n t))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3422 ((eq reftex-auto-show-entry 'copy)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3423 (let ((string (buffer-substring beg end)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3424 (switch-to-buffer "*RefTeX Context Copy*")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3425 (setq buffer-read-only nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3426 (erase-buffer)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3427 (insert string)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3428 (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
3429 (goto-char (- pos beg))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3430 (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
3431 (1+ (- (point) end-hlt)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3432 (when (reftex-refontify)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3433 (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
3434 (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
3435 (font-lock-mode 1)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3436 (setq buffer-read-only t)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3437 ))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3438
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3439 (defun reftex-nicify-text (text)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3440 ;; 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
3441 ;; 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
3442 (while (string-match "[\n\r\t]\\|[ \t][ \t]+" text)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3443 (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
3444 ;; 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
3445 (if (string-match "\\(\\\\end{\\|\\\\item\\|\\\\\\\\\\).*" text)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3446 (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
3447 ;; kill the embedded label
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3448 (if (string-match "\\\\label{[^}]*}" text)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3449 (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
3450 ;; remove leading garbage
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3451 (if (string-match "\\`[ }]+" text)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3452 (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
3453 ;; limit length
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3454 (cond
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3455 ((> (length text) 100) (substring text 0 100))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3456 ((= (length text) 0) " ")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3457 (t text)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3458
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3459 (defun reftex-typekey-check (typekey conf-variable &optional n)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3460 ;; Check if CONF-VARIABLE is true or contains TYPEKEY
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3461 (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
3462 (or (eq conf-variable t)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3463 (and (stringp conf-variable)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3464 (string-match (concat "[" conf-variable "]") typekey))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3465
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3466 ;;; ===========================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3467 ;;;
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3468 ;;; Table of contents
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3469
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3470 ;; 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
3471
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3472 (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
3473 "Keymap used for *toc* buffer.")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3474
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3475 (defun reftex-toc-mode ()
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3476 "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
3477 This buffer was created with RefTeX.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3478 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
3479
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3480 Here are all local bindings.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3481
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3482 \\{reftex-toc-map}"
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3483 (interactive)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3484 (kill-all-local-variables)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3485 (setq major-mode 'reftex-toc-mode
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3486 mode-name "RefTeX Table of Contents")
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3487 (use-local-map reftex-toc-map)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3488 (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
3489 (setq truncate-lines t)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3490 (make-local-hook 'post-command-hook)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3491 (make-local-hook 'pre-command-hook)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3492 (make-local-variable 'reftex-last-follow-point)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3493 (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
3494 (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
3495 (run-hooks 'reftex-toc-mode-hook))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3496
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3497 (defvar reftex-last-toc-master nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3498 "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
3499
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3500 (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
3501 "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
3502
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3503 (defvar reftex-last-window-height nil)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3504
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3505 (defvar reftex-toc-return-marker (make-marker)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3506 "Marker which makes it possible to return from toc to old position.")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3507
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3508 (defconst reftex-toc-help
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3509 " AVAILABLE KEYS IN TOC BUFFER
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3510 ============================
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3511 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
3512 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
3513 TAB Goto the section.
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3514 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
3515 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
3516 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
3517 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
3518 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
3519
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3520 (defun reftex-toc ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3521 "Show the table of contents for the current document.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3522 When called with a raw C-u prefix, rescan the document first."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3523
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3524 (interactive)
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 (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
3527 current-prefix-arg)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3528 (reftex-erase-buffer "*toc*"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3529
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3530 (setq reftex-last-toc-file (buffer-file-name))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3531 (setq reftex-last-toc-master (reftex-TeX-master-file))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3532
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3533 (set-marker reftex-toc-return-marker (point))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3534
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3535 ;; If follow mode is active, arrange to delay it one command
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3536 (if reftex-toc-follow-mode
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3537 (setq reftex-toc-follow-mode 1))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3538
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3539 ;; 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
3540 (reftex-access-scan-info current-prefix-arg)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3541
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3542 (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
3543 (xr-data (assq 'xr all))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3544 (xr-alist (cons (cons "" (buffer-file-name)) (nth 1 xr-data)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3545 (where (reftex-nearest-section))
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
3546 (mouse-face
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
3547 (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
3548 reftex-mouse-selected-face
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
3549 nil))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3550 toc1 cell startpos)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3551
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3552 (if (get-buffer-window "*toc*")
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3553 (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
3554 (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
3555 (delete-other-windows))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3556 (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
3557 (split-window)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3558 (let ((default-major-mode 'reftex-toc-mode))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3559 (switch-to-buffer "*toc*")))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3560
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3561 (or (eq major-mode 'reftex-toc-mode) (reftex-toc-mode))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3562
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3563 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3564 ;; buffer is empty - fill it with the table of contents
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3565 ((= (buffer-size) 0)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3566 (message "Building *toc* buffer...")
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3567
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3568 (setq buffer-read-only nil)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3569 (insert (format
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3570 "TABLE-OF-CONTENTS on %s
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3571 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
3572 -------------------------------------------------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3573 " (abbreviate-file-name reftex-last-toc-master)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3574 (setq startpos (point))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3575
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3576 (if (reftex-use-fonts)
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
3577 (put-text-property 1 (point) 'face reftex-toc-header-face))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3578 (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
3579 (put-text-property 1 2 'xr-alist xr-alist)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3580
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3581 (while all
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3582 (setq cell (car all)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3583 all (cdr all))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3584 (when (eq (car cell) 'toc)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3585 (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
3586 (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
3587 (when mouse-face
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3588 (put-text-property 0 (1- (length toc1))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3589 'mouse-face mouse-face toc1))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3590 (insert toc1)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3591
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3592 (backward-delete-char 1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3593
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3594 (message "Building *toc* buffer...done.")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3595 (setq buffer-read-only t))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3596 (t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3597 (goto-line 3)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3598 (beginning-of-line)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3599 (setq startpos (point))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3600
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3601 ;; Find the correct section
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3602 (goto-char (point-max))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3603 (beginning-of-line)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3604 (while (and (> (point) startpos)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3605 (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
3606 (beginning-of-line 0))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3607 (setq reftex-last-follow-point (point))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3608
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3609 (defun reftex-nearest-section ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3610 ;; 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
3611 (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
3612 (reftex-last-assoc-before-elt
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3613 'toc here-I-am (symbol-value reftex-docstruct-symbol))))
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 (defun reftex-toc-pre-command-hook ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3616 ;; used as pre command hook in *toc* buffer
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3617 (reftex-unhighlight 0)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3618 (reftex-unhighlight 1))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3619
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3620 (defun reftex-toc-post-command-hook ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3621 ;; used in the post-command-hook for the *toc* buffer
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3622 (and (> (point) 1)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3623 (memq reftex-highlight-selection '(cursor both))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3624 (save-excursion
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3625 (reftex-highlight 1
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3626 (progn (beginning-of-line) (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3627 (progn (end-of-line) (point)))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3628 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3629 ((integerp reftex-toc-follow-mode)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3630 ;; remove delayed action
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3631 (setq reftex-toc-follow-mode t))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3632 ((and reftex-toc-follow-mode
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3633 (not (equal reftex-last-follow-point (point))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3634 ;; show context in other window
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3635 (setq reftex-last-follow-point (point))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3636 (condition-case nil
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3637 (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
3638 (error t)))))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3639
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3640 (defun reftex-re-enlarge ()
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3641 (enlarge-window
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3642 (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
3643 (window-height)))))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3644
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3645 (defun reftex-toc-show-help ()
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3646 (interactive)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3647 (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
3648 (princ reftex-toc-help))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3649 ;; 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
3650 (if reftex-toc-follow-mode
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3651 (setq reftex-toc-follow-mode 1)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3652
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3653 (defun reftex-toc-toggle-follow ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3654 "Toggle toc-follow mode.
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
3655 (It is not really a mode, just a flag)."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3656 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3657 (setq reftex-toc-follow-mode (not reftex-toc-follow-mode)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3658 (defun reftex-toc-view-line ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3659 "View document location in other window."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3660 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3661 (reftex-toc-visit-line))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3662 (defun reftex-toc-mouse-view-line (ev)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3663 "View document location in other window."
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3664 (interactive "e")
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3665 (mouse-set-point ev)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3666 (reftex-toc-visit-line))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3667 (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
3668 "Go to document location in other window. Hide the *toc* window."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3669 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3670 (reftex-toc-visit-line 'hide))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3671 (defun reftex-toc-goto-line ()
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3672 "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
3673 (interactive)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3674 (reftex-toc-visit-line t))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3675 (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
3676 "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
3677 (interactive "e")
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3678 (mouse-set-point ev)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3679 (reftex-toc-visit-line 'hide))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3680 (defun reftex-toc-quit ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3681 "Hide the *toc* window and do not move point."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3682 (interactive)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3683 (or (one-window-p) (delete-window))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3684 (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
3685 (reftex-re-enlarge)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3686 (goto-char (or (marker-position reftex-toc-return-marker) (point))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3687 (defun reftex-toc-quit-and-kill ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3688 "Kill the *toc* buffer."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3689 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3690 (kill-buffer "*toc*")
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3691 (or (one-window-p) (delete-window))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3692 (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
3693 (reftex-re-enlarge)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3694 (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
3695 (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
3696 "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
3697 (interactive)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3698 (if reftex-enable-partial-scans
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3699 (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
3700 (if (not file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3701 (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
3702 (switch-to-buffer-other-window
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3703 (reftex-get-file-buffer-force file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3704 (setq current-prefix-arg '(4))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3705 (reftex-toc)))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3706 (reftex-toc-Rescan))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3707 (reftex-kill-temporary-buffers))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3708 (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
3709 "Regenerate the *toc* buffer by reparsing the entire document."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3710 (interactive)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3711 (switch-to-buffer-other-window
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3712 (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
3713 (setq current-prefix-arg '(16))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3714 (reftex-toc))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3715 (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
3716 "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
3717 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3718 (switch-to-buffer-other-window
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3719 (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
3720 (reftex-erase-buffer "*toc*")
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3721 (setq current-prefix-arg nil)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3722 (reftex-toc))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3723 (defun reftex-toc-external (&rest ignore)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3724 "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
3725 (interactive)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3726 (let* ((old-buf (current-buffer))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3727 (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
3728 (xr-index (reftex-select-external-document
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3729 xr-alist 0)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3730 (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
3731 (cdr (nth xr-index xr-alist)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3732 (error "Cannot switch document")))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3733 (reftex-toc)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3734 (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
3735 (message "")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3736 (message "Switched document"))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3737
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3738 (defun reftex-toc-visit-line (&optional final no-revisit)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3739 ;; 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
3740 ;; If FINAL is t, stay there
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3741 ;; 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
3742 ;; 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
3743 ;; 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
3744 ;; 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
3745 ;; have been active.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3746
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3747 (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
3748 (file (nth 3 toc))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3749 (marker (nth 4 toc))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3750 (level (nth 5 toc))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3751 (literal (nth 7 toc))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3752 (emergency-point (nth 8 toc))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3753 (toc-window (selected-window))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3754 show-window show-buffer match)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3755
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3756 (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
3757
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3758 (setq match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3759 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3760 ((and (markerp marker) (marker-buffer marker))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3761 ;; 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
3762 (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
3763 (goto-char (marker-position marker))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3764 (or (looking-at (regexp-quote literal))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3765 (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
3766 (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
3767 (looking-at (concat "\\\\"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3768 (regexp-quote
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3769 (car (rassq level reftex-section-levels)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3770 "[[{]"))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3771 ((or (not no-revisit)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3772 (get-file-buffer file))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3773 ;; 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
3774 (switch-to-buffer-other-window
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3775 (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
3776 (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
3777 (or (looking-at (regexp-quote literal))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3778 (let ((pos (point)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3779 (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
3780 (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
3781 (reftex-nearest-match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3782 (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
3783 (reftex-nearest-match
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3784 (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
3785 ))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3786
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3787 (setq show-window (selected-window)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3788 show-buffer (current-buffer))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3789
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3790 (unless match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3791 (select-window toc-window)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3792 (error "Cannot find line"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3793
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3794 (goto-char (match-beginning 0))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3795 (recenter 1)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3796 (reftex-highlight 0 (match-beginning 0) (match-end 0) (current-buffer))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3797
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3798 (select-window toc-window)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3799
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3800 ;; use the `final' parameter to decide what to do next
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3801 (cond
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3802 ((eq final t)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3803 (reftex-unhighlight 0)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3804 (select-window show-window))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3805 ((eq final 'hide)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3806 (reftex-unhighlight 0)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3807 (or (one-window-p) (delete-window))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3808 (switch-to-buffer show-buffer)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3809 (reftex-re-enlarge))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3810 (t nil))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3811
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3812 ;;; ===========================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3813 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3814 ;;; BibTeX citations.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3815
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3816 ;; Variables and constants
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3817
18219
aaeaae005e98 Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents: 18123
diff changeset
3818 ;; 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
3819 (defvar reftex-cite-format-builtin)
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 ;; The history list of regular expressions used for citations
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3822 (defvar reftex-cite-regexp-hist nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3823
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3824 ;; 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
3825 (defconst reftex-citation-prompt
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3826 "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
3827
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3828 (defconst reftex-citation-help
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3829 " 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
3830 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
3831 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
3832 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
3833 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
3834 . Show insertion point.
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
3835 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
3836 TAB Enter citation key with completion.
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3837 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
3838 a Accept all entries.")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3839
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3840 (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
3841 "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
3842 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
3843 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
3844
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3845 (defun reftex-select-bib-mode ()
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3846 "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
3847 This buffer was created with RefTeX.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3848 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
3849 selection process.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3850 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
3851 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
3852
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3853 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
3854
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3855 \\{reftex-select-label-map}"
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3856 (interactive)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3857 (kill-all-local-variables)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3858 (make-local-hook 'pre-command-hook)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3859 (make-local-hook 'post-command-hook)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3860 (setq major-mode 'reftex-select-bib-mode
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3861 mode-name "RefTeX Select Bib")
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3862 ;; 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
3863 (run-hooks 'reftex-select-bib-mode-hook))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
3864
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3865 ;; Find bibtex files
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3866
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3867 (defun reftex-get-bibfile-list ()
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3868 ;; 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
3869 ;; 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
3870 ;; 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
3871 ;; 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
3872 ;; Then this function will return the applicable database files.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3873
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3874 ;; Ensure access to scanning info
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3875 (reftex-access-scan-info)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3876 (or
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3877 ;; 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
3878 (cdr (reftex-last-assoc-before-elt
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3879 'bib (list 'eof (buffer-file-name))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3880 (member (list 'bof (buffer-file-name))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3881 (symbol-value reftex-docstruct-symbol))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3882 ;; 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
3883 (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
3884 (symbol-value reftex-docstruct-symbol))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3885 ;; Anywhere in the entire document
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3886 (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
3887 (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
3888
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3889 (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
3890 ;; 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
3891 ;; 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
3892 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3893 ((file-name-absolute-p file)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3894 (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
3895 (t
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3896 (reftex-access-search-path "tex")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3897 (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
3898 file1)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3899 (setq file1
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3900 (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
3901 (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
3902 (unless file1
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3903 (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
3904 (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
3905 (setq file1
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3906 (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
3907 (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
3908 (cond (file1 file1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3909 (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
3910 (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
3911
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3912 (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
3913 ;; 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
3914 (reftex-access-search-path "bib")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3915 (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
3916 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
3917 (unless file1
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3918 (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
3919 (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
3920 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
3921 (cond (file1 file1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3922 (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
3923 (t (message "No such file: %s (ignored)" file) nil))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3924
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3925 ;; Find a certain reference in any of the BibTeX files.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3926
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3927 (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
3928 &optional mark-to-kill highlight item)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3929 ;; 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
3930 ;; 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
3931 ;; 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
3932 ;; 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
3933
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3934 (let* ((re
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3935 (if item
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3936 (concat "\\\\bibitem\\(\\[[^]]*\\]\\)?{" (regexp-quote key) "}")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3937 (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
3938 (window-conf (current-window-configuration))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3939 file buf)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3940
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3941 (catch 'exit
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3942 (switch-to-buffer-other-window (current-buffer))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3943 (while file-list
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3944 (setq file (car file-list)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3945 file-list (cdr file-list))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3946 (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
3947 (error "No such file %s" file))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3948 (switch-to-buffer buf)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3949 (widen)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3950 (goto-char (point-min))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3951 (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
3952 (goto-char (match-beginning 0))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3953 (recenter 0)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3954 (if highlight
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3955 (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
3956 (throw 'exit (selected-window))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3957 (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
3958 (if item
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
3959 (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
3960 (message "No BibTeX entry with citation key %s" key)))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3961
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3962 ;; Parse bibtex buffers
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3963
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3964 (defun reftex-extract-bib-entries (buffers &optional get-word)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3965 ;; Extract bib entries which match regexps from BUFFERS.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3966 ;; BUFFERS is a list of buffers or file names.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3967 ;; Return list with entries."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3968 (let* (re-list first-re rest-re
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3969 (buffer-list (if (listp buffers) buffers (list buffers)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3970 found-list entry buffer1 buffer alist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3971 key-point start-point end-point)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3972
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3973 (setq re-list (split-string
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3974 (read-string "RegExp [ && RegExp...]: "
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3975 nil 'reftex-cite-regexp-hist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3976 "[ \t]*&&[ \t]*"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3977
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3978 (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
3979 rest-re (cdr re-list)) ; the others to narrow down.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3980 (if (string-match "\\`[ \t]*\\'" first-re)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3981 (error "Empty regular expression"))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3982
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3983 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3984 (save-window-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3985
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
3986 ;; Walk through all bibtex files
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3987 (while buffer-list
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3988 (setq buffer (car buffer-list)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3989 buffer-list (cdr buffer-list))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3990 (if (and (bufferp buffer)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3991 (buffer-live-p buffer))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3992 (setq buffer1 buffer)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3993 (setq buffer1 (reftex-get-file-buffer-force
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3994 buffer (not reftex-keep-temporary-buffers))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3995 (if (not buffer1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3996 (error "Cannot find BibTeX file %s" buffer)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3997 (message "Scanning bibliography database %s" buffer1))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3998
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3999 (set-buffer buffer1)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4000 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4001 (goto-char (point-min))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4002 (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
4003 (catch 'search-again
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4004 (setq key-point (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4005 (unless (re-search-backward
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4006 "\\(\\`\\|[\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
4007 (throw 'search-again nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4008 (setq start-point (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4009 (goto-char (match-end 0))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4010 (condition-case nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4011 (up-list 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4012 (error (goto-char key-point)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4013 (throw 'search-again nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4014 (setq end-point (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4015
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4016 ;; 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
4017 ;; outside entries
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4018 (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
4019 (string= (downcase (match-string 2)) "comment")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4020 (string= (downcase (match-string 2)) "c")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4021 (< (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
4022 (goto-char key-point)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4023 (throw 'search-again nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4024
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4025 ;; Well, we have got a match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4026 (setq entry (concat
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4027 (buffer-substring start-point (point)) "\n"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4028
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4029 ;; 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
4030 (setq re-list rest-re)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4031 (while re-list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4032 (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
4033 ;; nope - move on
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4034 (throw 'search-again nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4035 (pop re-list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4036
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4037 (setq alist (reftex-parse-bibtex-entry
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4038 nil start-point end-point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4039 (push (cons "&entry" entry) alist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4040
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4041 ;; check for crossref entries
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4042 (if (assoc "crossref" alist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4043 (setq alist
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4044 (append
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4045 alist (reftex-get-crossref-alist alist))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4046
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4047 ;; format the entry
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4048 (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
4049 alist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4050
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4051 ;; add it to the list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4052 (push alist found-list))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4053 (reftex-kill-temporary-buffers))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4054 (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
4055
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4056 ;; Sorting
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4057 (cond
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4058 ((eq 'author reftex-sort-bibtex-matches)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4059 (sort found-list 'reftex-bib-sort-author))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4060 ((eq 'year reftex-sort-bibtex-matches)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4061 (sort found-list 'reftex-bib-sort-year))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4062 ((eq 'reverse-year reftex-sort-bibtex-matches)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4063 (sort found-list 'reftex-bib-sort-year-reverse))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4064 (t found-list))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4065
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4066 (defun reftex-bib-sort-author (e1 e2)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4067 (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
4068 (al2 (reftex-get-bib-names "author" e2)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4069 (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
4070 (pop al1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4071 (pop al2))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4072 (if (and (stringp (car al1))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4073 (stringp (car al2)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4074 (string< (car al1) (car al2))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4075 (not (stringp (car al1))))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4076
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4077 (defun reftex-bib-sort-year (e1 e2)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4078 (< (string-to-int (cdr (assoc "year" e1)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4079 (string-to-int (cdr (assoc "year" e2)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4080
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4081 (defun reftex-bib-sort-year-reverse (e1 e2)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4082 (> (string-to-int (or (cdr (assoc "year" e1)) "0"))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4083 (string-to-int (or (cdr (assoc "year" e2)) "0"))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4084
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4085 (defun reftex-get-crossref-alist (entry)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4086 ;; return the alist from a crossref entry
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4087 (let ((crkey (cdr (assoc "crossref" entry)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4088 start)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4089 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4090 (save-restriction
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4091 (widen)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4092 (if (re-search-forward
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4093 (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
4094 "[ \t\n\r]*,") nil t)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4095 (progn
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4096 (setq start (match-beginning 0))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4097 (condition-case nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4098 (up-list 1)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4099 (error nil))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4100 (reftex-parse-bibtex-entry nil start (point)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4101 nil)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4102
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4103 ;; Parse the thebibliography environment
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4104 (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
4105 ;; 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
4106 ;; 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
4107 ;; 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
4108
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4109 (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
4110 (unless file
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4111 (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
4112 (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
4113 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
4114 (unless buf
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4115 (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
4116 (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
4117
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4118 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4119 (set-buffer buf)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4120 (save-restriction
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4121 (widen)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4122 (goto-char (point-min))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4123 (if (re-search-forward
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4124 "\\(\\`\\|[\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
4125 (progn
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4126 (beginning-of-line 2)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4127 (setq start (point))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4128 (if (re-search-forward
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4129 "\\(\\`\\|[\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
4130 (progn
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4131 (beginning-of-line 1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4132 (setq end (point))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4133 (when (and start (point))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4134 (setq entries
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4135 (mapcar 'reftex-parse-bibitem
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4136 (delete ""
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4137 (split-string
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4138 (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
4139 "[ \t\n\r]*\\\\bibitem\\(\\[[^]]*]\\)*")))))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4140 (unless entries
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4141 (error "No bibitems found"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4142
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4143 (setq re-list (split-string
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4144 (read-string "RegExp [ && RegExp...]: "
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4145 nil 'reftex-cite-regexp-hist)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4146 "[ \t]*&&[ \t]*"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4147 (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
4148 (error "Empty regular expression"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4149
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4150 (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
4151 (setq entries
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4152 (delete nil (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4153 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4154 (lambda (x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4155 (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
4156 x nil)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4157 entries))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4158
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4159 (setq entries
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4160 (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4161 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4162 (lambda (x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4163 (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
4164 entries))
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 entries))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4167
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4168 ;; Parse and format individual entries
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4169
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4170 (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
4171 ;; 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
4172 (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
4173 (if (equal "" names)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4174 (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
4175 (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
4176 (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
4177 (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
4178 (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
4179 (while (string-match "^[ \t]+\\|[ \t]+$" names)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4180 (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
4181 (while (string-match "[ \t][ \t]+" names)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4182 (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
4183 (split-string names "\n")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4184
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4185 (defun reftex-parse-bibtex-entry (entry &optional from to)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4186 (let (alist key start field)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4187 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4188 (save-restriction
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4189 (if entry
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4190 (progn
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4191 (switch-to-buffer "*RefTeX-scratch*")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4192 (fundamental-mode)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4193 (erase-buffer)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4194 (insert entry))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4195 (widen)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4196 (narrow-to-region from to))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4197 (goto-char (point-min))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4198
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4199 (if (re-search-forward
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
4200 "@\\(\\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
4201 (setq alist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4202 (list
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4203 (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
4204 (cons "&key" (reftex-match-string 2)))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4205 (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
4206 (setq key (downcase (reftex-match-string 1)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4207 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4208 ((= (following-char) ?{)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4209 (forward-char 1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4210 (setq start (point))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4211 (condition-case nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4212 (up-list 1)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4213 (error nil)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4214 ((= (following-char) ?\")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4215 (forward-char 1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4216 (setq start (point))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4217 (while (and (search-forward "\"" nil t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4218 (= ?\\ (char-after (- (point) 2))))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4219 (t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4220 (setq start (point))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4221 (re-search-forward "[ \t\n\r,}]" nil 1)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4222 (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
4223 ;; remove extra whitespace
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4224 (while (string-match "[\n\t\r]\\|[ \t][ \t]+" field)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4225 (setq field (replace-match " " nil t field)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4226 ;; remove leading garbage
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4227 (if (string-match "^[ \t{]+" field)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4228 (setq field (replace-match "" nil t field)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4229 ;; remove trailing garbage
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4230 (if (string-match "[ \t}]+$" field)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4231 (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
4232 (push (cons key field) alist))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4233 alist))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4234
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4235 (defun reftex-get-bib-field (fieldname entry)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4236 ;; Extract the field FIELDNAME from an ENTRY
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4237 (or (cdr (assoc fieldname entry))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4238 ""))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4239
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4240 (defun reftex-format-bib-entry (entry)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4241 ;; Format a BibTeX ENTRY so that it is nice to look at
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4242 (let*
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4243 ((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
4244 (authors (mapconcat 'identity auth-list ", "))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4245 (year (reftex-get-bib-field "year" entry))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4246 (title (reftex-get-bib-field "title" entry))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4247 (type (reftex-get-bib-field "&type" entry))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4248 (key (reftex-get-bib-field "&key" entry))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4249 (extra
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4250 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4251 ((equal type "article")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4252 (concat (reftex-get-bib-field "journal" entry) " "
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4253 (reftex-get-bib-field "volume" entry) ", "
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4254 (reftex-get-bib-field "pages" entry)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4255 ((equal type "book")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4256 (concat "book (" (reftex-get-bib-field "publisher" entry) ")"))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4257 ((equal type "phdthesis")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4258 (concat "PhD: " (reftex-get-bib-field "school" entry)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4259 ((equal type "mastersthesis")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4260 (concat "Master: " (reftex-get-bib-field "school" entry)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4261 ((equal type "inbook")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4262 (concat "Chap: " (reftex-get-bib-field "chapter" entry)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4263 ", pp. " (reftex-get-bib-field "pages" entry)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4264 ((or (equal type "conference")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4265 (equal type "incollection")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4266 (equal type "inproceedings"))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4267 (concat "in: " (reftex-get-bib-field "booktitle" entry)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4268 (t ""))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4269 (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
4270 (when (reftex-use-fonts)
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4271 (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
4272 authors)
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4273 (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
4274 year)
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4275 (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
4276 title)
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4277 (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
4278 extra))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4279 (concat key "\n " authors " " year " " extra "\n " title "\n\n")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4280
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4281 (defun reftex-parse-bibitem (item)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4282 ;; Parse a \bibitem entry
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4283 (let ((key "") (text ""))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4284 (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
4285 (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
4286 text (match-string 2 item)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4287 ;; 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
4288 (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
4289 (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
4290 (if (string-match "\\`[ \t]+" text)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4291 (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
4292 (list
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4293 (cons "&key" key)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4294 (cons "&text" text)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4295 (cons "&entry" (concat key " " text)))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4296
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4297 (defun reftex-format-bibitem (item)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4298 ;; 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
4299 (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
4300 (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
4301 (lines nil))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4302
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4303 ;; 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
4304 (while (and (> (length text) 70)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4305 (string-match " " (substring text 60)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4306 (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
4307 (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
4308 (push text lines)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4309 (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
4310
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4311 (when (reftex-use-fonts)
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4312 (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
4313 (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
4314
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4315 ;; Make a citation
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4316
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4317 (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
4318 "Make a citation using BibTeX database files.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4319 After asking for a Regular Expression, it scans the buffers with
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4320 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
4321 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
4322 to `reftex-cite-format' and inserted into the buffer.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4323 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
4324 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
4325 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
4326 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
4327 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
4328 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
4329 put into the same \\cite command.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4330 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
4331 bibliography statement (e.g. if it was changed)."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4332
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4333 (interactive)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4334
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4335 ;; check for recursive edit
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4336 (reftex-check-recursive-edit)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4337
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4338 ;; 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
4339 (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
4340
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4341 ;; Call reftex-do-citation, but protected
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4342 (unwind-protect
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4343 (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
4344 (reftex-kill-temporary-buffers)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4345
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4346 (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
4347 ;; 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
4348
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4349 ;; 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
4350 ;; 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
4351 (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
4352 (if (and (stringp macro)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4353 (string-match "\\`\\\\cite\\|cite\\'" macro))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4354 (progn
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4355 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4356 ((or (not arg)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4357 (not (listp arg)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4358 (setq format
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4359 (concat
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4360 (if (not (or (= (preceding-char) ?{)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4361 (= (preceding-char) ?,)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4362 ","
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4363 "")
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4364 "%l"
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4365 (if (not (or (= (following-char) ?})
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4366 (= (following-char) ?,)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4367 ","
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4368 ""))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4369 (t
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4370 (setq format "%l"))))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4371 ;; else: figure out the correct format
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4372 (setq format
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4373 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4374 ((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
4375 ((and (symbolp reftex-cite-format)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4376 (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
4377 (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
4378 (t reftex-cite-format)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4379 (if (listp format)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4380 (save-window-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4381 (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
4382 (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
4383 (princ
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4384 (mapconcat
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4385 (function (lambda (x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4386 (format "[%c] %s %s" (car x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4387 (if (> (car x) 31) " " "")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4388 (cdr x))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4389 format "\n")))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4390 (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
4391 (setq key (read-char))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4392 (if (assq key format)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4393 (setq format (cdr (assq key format)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4394 (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
4395
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4396 (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
4397
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4398 ;; Scan bibtex files
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4399 (setq found-list
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4400 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4401 ((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
4402 ;; using BibTeX database files.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4403 (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
4404 ((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
4405 ;; using thebibliography environment.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4406 (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
4407 (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
4408 (reftex-default-bibliography
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4409 (message "Using default bibliography")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4410 (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
4411 (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
4412
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4413 (unless found-list
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4414 (error "Sorry, no matches found"))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4415
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4416 ;; remember where we came from
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4417 (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
4418 (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
4419
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4420 ;; offer selection
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4421 (save-window-excursion
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4422 (delete-other-windows)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4423 (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
4424 (reftex-kill-buffer "*RefTeX Select*")
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4425 (switch-to-buffer-other-window "*RefTeX Select*")
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4426 (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
4427 (reftex-select-bib-mode))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4428 (let ((buffer-read-only nil))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4429 (erase-buffer)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4430 (reftex-insert-bib-matches found-list)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4431 (setq buffer-read-only t)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4432 (if (= 0 (buffer-size))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4433 (error "Sorry, no matches found"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4434 (setq truncate-lines t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4435 (goto-char 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4436 (if (catch 'exit
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4437 (while t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4438 (setq rtn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4439 (reftex-select-item
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4440 reftex-citation-prompt
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4441 reftex-citation-help
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4442 reftex-select-bib-map
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4443 nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4444 'reftex-bibtex-selection-callback nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4445 (setq key (car rtn)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4446 data (nth 1 rtn))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4447 (unless key (throw 'exit nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4448 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4449 ((eq key ?g)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4450 (setq found-list
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4451 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4452 (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
4453 (reftex-extract-bib-entries
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4454 (reftex-get-bibfile-list))))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4455 (let ((buffer-read-only nil))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4456 (erase-buffer)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4457 (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
4458 (if (= 0 (buffer-size))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4459 (error "Sorry, no matches found"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4460 (goto-char 1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4461
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4462 ((eq key ?r)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4463 ;; restrict with new regular expression
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4464 (setq re-list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4465 (split-string (read-string
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4466 "RegExp [ && RegExp...]: "
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4467 nil 'reftex-cite-regexp-hist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4468 "[ \t]*&&[ \t]*"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4469 (while re-list
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4470 (setq re (car re-list)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4471 re-list (cdr re-list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4472 (setq found-list-r
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4473 (delete ""
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4474 (mapcar
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4475 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4476 (lambda (x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4477 (if (string-match
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4478 re (cdr (assoc "&entry" x)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4479 x
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4480 "")))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4481 found-list))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4482 (if found-list-r
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4483 (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
4484 (ding))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4485 (let ((buffer-read-only nil))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4486 (erase-buffer)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4487 (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
4488 (goto-char 1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4489 ((eq key ?a)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4490 (setq entry 'all)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4491 (throw 'exit t))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4492 ((or (eq key ?\C-m)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4493 (eq key 'return))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4494 (if data
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4495 (setq entry data)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4496 (setq entry nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4497 (throw 'exit t))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4498 ((stringp key)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4499 (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
4500 (throw 'exit t))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4501 (t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4502 (ding)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4503 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4504 ;; format the entry
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4505 (if (eq entry 'all)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4506 (setq ins-string
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4507 (mapconcat
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4508 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4509 (lambda (entry)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4510 (if reftex-format-cite-function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4511 (funcall reftex-format-cite-function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4512 (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
4513 format)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4514 (reftex-format-citation entry format))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4515 found-list "\n"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4516 (setq ins-string
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4517 (if reftex-format-cite-function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4518 (funcall reftex-format-cite-function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4519 (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
4520 format)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4521 (reftex-format-citation entry format)))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4522 (setq ins-string "")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4523 (message "Quit")))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4524 (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
4525 (kill-buffer "*RefTeX Select*")
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4526
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4527 (unless no-insert
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4528 (insert ins-string)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4529 (when (string-match "\\?" ins-string)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4530 (search-backward "?")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4531 (delete-char 1)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4532 (message "")
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4533
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4534 ;; 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
4535 (when (and (integerp arg)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4536 (> arg 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4537 (re-search-backward
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4538 "\\\\\\([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
4539 (goto-char (match-end 0))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4540 (decf arg)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4541 (reftex-do-citation arg))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4542
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4543 ;; Return the citation key
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4544 (or (eq entry 'all)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4545 (reftex-get-bib-field "&key" entry)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4546
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4547 (defun reftex-insert-bib-matches (list)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4548 ;; 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
4549 (let ((mouse-face
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4550 (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
4551 reftex-mouse-selected-face
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4552 nil))
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
4553 tmp len)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4554 (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4555 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4556 (lambda (x)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4557 (setq tmp (cdr (assoc "&formatted" x))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4558 len (length tmp))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4559 (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
4560 (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
4561 (insert tmp)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4562 list)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4563
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4564 (defun reftex-format-names (namelist n)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4565 (let (last (len (length namelist)))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4566 (cond
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4567 ((= 1 len) (car namelist))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4568 ((> 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
4569 (t
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4570 (setq n (min len n)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4571 last (nth (1- n) namelist))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4572 (setcdr (nthcdr (- n 2) namelist) nil)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4573 (concat
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4574 (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
4575 (nth 1 reftex-cite-punctuation)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4576 last)))))
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4577
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4578 (defun reftex-format-citation (entry format)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4579 ;; 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
4580
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4581 (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
4582
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4583 (if (and reftex-comment-citations
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4584 (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
4585 (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
4586
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4587 (while (string-match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4588 "\\(\\`\\|[^%]\\)\\(\\(%\\([0-9]*\\)\\([a-zA-Z]\\)\\)[.,;: ]*\\)"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4589 format)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4590 (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
4591 (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
4592 rpl b e)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4593 (save-match-data
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4594 (setq rpl
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4595 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4596 ((= l ?l) (concat
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4597 (reftex-get-bib-field "&key" entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4598 (if reftex-comment-citations
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4599 reftex-cite-comment-format
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4600 "")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4601 ((= l ?a) (reftex-format-names
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4602 (reftex-get-bib-names "author" entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4603 (or n 2)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4604 ((= 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
4605 ((= 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
4606 ((= 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
4607 ((= 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
4608 ((= l ?e) (reftex-format-names
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4609 (reftex-get-bib-names "editor" entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4610 (or n 2)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4611 ((= 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
4612 ((= 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
4613 ((= 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
4614 ((= 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
4615 ((= 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
4616 ((= 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
4617 ((= 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
4618 ((= 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
4619 ((= 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
4620 ((= l ?P) (car (split-string
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4621 (reftex-get-bib-field "pages" entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4622 "[- .]+")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4623 ((= 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
4624 ((= 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
4625 ((= 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
4626 ((= 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
4627 ((= 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
4628 ((= 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
4629
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4630 (if (string= rpl "")
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4631 (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
4632 (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
4633 (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
4634 (while (string-match "%%" format)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4635 (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
4636 (while (string-match "[ ,.;:]*%<" format)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4637 (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
4638 format)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4639
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4640 (defun reftex-bibtex-selection-callback (data ignore no-revisit)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4641 ;; 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
4642 ;; 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
4643 ;; recommended for follow mode. It works OK for individual lookups.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4644 (let ((win (selected-window))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4645 (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
4646 bibfile-list item tmp)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4647
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4648 (catch 'exit
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4649 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4650 (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
4651 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4652 ((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
4653 (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
4654 ((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
4655 (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
4656 item t))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4657 (reftex-default-bibliography
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4658 (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
4659 (t (ding) (throw 'exit))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4660
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4661 (when no-revisit
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4662 (setq bibfile-list
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4663 (delq nil (mapcar (lambda (x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4664 (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
4665 bibfile-list))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4666
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4667 (reftex-pop-to-bibtex-entry
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4668 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
4669
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4670 (select-window win)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4671
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4672 ;;; ===========================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4673 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4674 ;;; Here is the routine used for selection
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4675
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4676 ;; Marker for return point from recursive edit
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4677 (defvar reftex-recursive-edit-marker (make-marker))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4678
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4679 (defvar reftex-last-data nil)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4680 (defvar reftex-last-line nil)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4681
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4682 (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
4683 ;; 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
4684 ;; message if so.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4685 (if (marker-position reftex-recursive-edit-marker)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4686 (error
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4687 (substitute-command-keys
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4688 "In unfinished selection process. Finish, or abort with \\[abort-recursive-edit]."))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4689
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4690 (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
4691 &optional offset
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4692 call-back cb-flag match-everywhere)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4693 ;; 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
4694 ;; 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
4695 ;; selected.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4696 ;; 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
4697 ;; selection commands.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4698 ;; 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
4699 ;; 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
4700 ;; 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
4701 ;; 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
4702 ;; of the element.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4703 ;; 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
4704 ;; When MATCH-EVERYWHERE is t, searches will also match in non-selectable
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4705 ;; places.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4706
21075
0c95fb73e090 1998-03-06 Carsten Dominik <cd@delysid.gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21002
diff changeset
4707 (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
4708
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4709 (setq ev
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4710 (catch 'myexit
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4711 (save-window-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4712 (setq truncate-lines t)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4713
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4714 ;; Find a good starting point
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4715 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4716 (offset
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4717 (goto-char
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4718 (or (and (listp offset)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4719 (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
4720 ':data offset))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4721 (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
4722 (boundp 'reftex-last-data)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4723 (listp reftex-last-data)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4724 (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
4725 ':data reftex-last-data))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4726 (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
4727 (boundp 'reftex-last-line)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4728 (integerp reftex-last-line)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4729 (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
4730 (point-min))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4731 (t (goto-char (point-min))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4732 (beginning-of-line 1)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4733 (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
4734
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4735 (unwind-protect
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4736 (progn
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4737 (use-local-map keymap)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4738 (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
4739 (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
4740 (princ prompt)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4741 (set-marker reftex-recursive-edit-marker (point))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4742 (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
4743 (recursive-edit))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4744
21075
0c95fb73e090 1998-03-06 Carsten Dominik <cd@delysid.gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21002
diff changeset
4745 (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
4746 (save-excursion
0c95fb73e090 1998-03-06 Carsten Dominik <cd@delysid.gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21002
diff changeset
4747 (set-buffer selection-buffer)
0c95fb73e090 1998-03-06 Carsten Dominik <cd@delysid.gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21002
diff changeset
4748 (use-local-map nil)
0c95fb73e090 1998-03-06 Carsten Dominik <cd@delysid.gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21002
diff changeset
4749 (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
4750 (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
4751 '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
4752
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4753 (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
4754 (+ (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
4755 (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
4756 (reftex-kill-buffer "*RefTeX Help*")
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4757 (message "")
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4758 (list ev data last-data)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4759
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4760 ;; 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
4761 ;; 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
4762
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4763 (defvar found-list)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4764 (defvar cb-flag)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4765 (defvar data)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4766 (defvar prompt)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4767 (defvar last-data)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4768 (defvar call-back)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4769 (defvar help-string)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4770 (defvar match-everywhere)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4771 (defvar callback-fwd)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4772 (defvar varioref)
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 ;; The selection commands
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4775
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4776 (defun reftex-select-pre-command-hook ()
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4777 (reftex-unhighlight 1)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4778 (reftex-unhighlight 0))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4779
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4780 (defun reftex-select-post-command-hook ()
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4781 (let (b e)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4782 (setq data (get-text-property (point) ':data))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4783 (setq last-data (or data last-data))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4784
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4785 (when (and data cb-flag
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4786 (not (equal reftex-last-follow-point (point))))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4787 (setq reftex-last-follow-point (point))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4788 (funcall call-back data callback-fwd
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4789 (not reftex-revisit-to-follow)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4790 (if data
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4791 (setq b (or (previous-single-property-change
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4792 (1+ (point)) ':data)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4793 (point-min))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4794 e (or (next-single-property-change
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4795 (point) ':data)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4796 (point-max)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4797 (setq b (point) e (point)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4798 (and (memq reftex-highlight-selection '(cursor both))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4799 (reftex-highlight 1 b e))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4800 (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
4801 (not (pos-visible-in-window-p e)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4802 (recenter (/ (window-height) 2)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4803 (when (and (fboundp 'current-message)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4804 (not (current-message)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4805 (princ prompt))))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4806
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4807 (defun reftex-select-next (&optional arg)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4808 (interactive "p")
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4809 (setq callback-fwd t)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4810 (or (eobp) (forward-char 1))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4811 (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
4812 (beginning-of-line 1))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4813 (defun reftex-select-previous (&optional arg)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4814 (interactive "p")
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4815 (setq callback-fwd nil)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4816 (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
4817 (defun reftex-select-next-heading (&optional arg)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4818 (interactive "p")
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4819 (end-of-line)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4820 (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
4821 (beginning-of-line))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4822 (defun reftex-select-previous-heading (&optional arg)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4823 (interactive "p")
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4824 (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
4825 (defun reftex-select-quit ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4826 (interactive)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4827 (throw 'myexit nil))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4828 (defun reftex-select-keyboard-quit ()
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4829 (interactive)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4830 (throw 'exit t))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4831 (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
4832 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4833 (let (pos)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4834 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4835 ((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
4836 reftex-last-data
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4837 (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
4838 ':data reftex-last-data)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4839 (goto-char pos))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4840 ((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
4841 (integerp reftex-last-line))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4842 (goto-line reftex-last-line))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4843 (t (ding)))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4844 (defun reftex-select-toggle-follow ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4845 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4846 (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
4847 (defun reftex-select-toggle-varioref ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4848 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4849 (if (string= varioref "\\ref")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4850 (setq varioref "\\vref")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4851 (setq varioref "\\ref"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4852 (force-mode-line-update))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4853 (defun reftex-select-show-insertion-point ()
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4854 (interactive)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4855 (let ((this-window (selected-window)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4856 (unwind-protect
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4857 (progn
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4858 (switch-to-buffer-other-window
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4859 (marker-buffer reftex-select-return-marker))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4860 (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
4861 (recenter (/ (window-height) 2)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4862 (select-window this-window))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4863 (defun reftex-select-callback ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4864 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4865 (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
4866 (defun reftex-select-accept ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4867 (interactive)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4868 (throw 'myexit 'return))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4869 (defun reftex-select-mouse-accept (ev)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4870 (interactive "e")
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4871 (mouse-set-point ev)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4872 (setq data (get-text-property (point) ':data))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4873 (setq last-data (or data last-data))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4874 (throw 'myexit 'return))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4875 (defun reftex-select-read-label ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4876 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4877 (let ((label (completing-read
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4878 "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
4879 nil nil reftex-prefix)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4880 (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
4881 (throw 'myexit label))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4882 (defun reftex-select-read-cite ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4883 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4884 (let* ((list (mapcar (lambda (x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4885 (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
4886 found-list))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4887 (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
4888 (unless (equal key "")
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4889 (throw 'myexit key))))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4890 (defun reftex-select-help ()
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4891 (interactive)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4892 (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
4893 (princ help-string))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
4894 (reftex-enlarge-to-fit "*RefTeX Help*" t))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4895
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4896 ;;; ===========================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4897 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4898 ;;; View cross references
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4899
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4900 (defun reftex-view-crossref (&optional arg)
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
4901 "View cross reference of \\ref or \\cite macro at point.
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
4902 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
4903 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
4904 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
4905 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
4906 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
4907 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
4908 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
4909 contain cross references.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4910 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
4911 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
4912 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
4913 argument.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4914 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
4915 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
4916
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4917 (interactive "P")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4918
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4919 ;; See where we are.
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4920 (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
4921 (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
4922 (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
4923 (my-window (selected-window))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4924 pop-window cmd args point)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4925
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4926 (if (and macro
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4927 (string-match "\\`\\\\cite\\|\\`\\\\ref\\|cite\\'\\|ref\\'"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4928 macro))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4929 (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
4930 (string-match "\\`\\\\" macro)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4931 (setq macro (substring macro 1)))
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
4932 (setq macro nil))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4933
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4934 (if (and macro
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4935 (eq last-command this-command)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4936 (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
4937 (if (string= macro "cite")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4938 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4939 (skip-chars-forward "^},%")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4940 (while (and (eq (following-char) ?%)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4941 (or (beginning-of-line 2) t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4942 (skip-chars-forward " \t\n\r")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4943 (skip-chars-forward ",")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4944 (if (eq (following-char) ?})
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4945 (setq macro nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4946 (setq macro nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4947
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4948 (if (and (not macro)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4949 (or (not (string-match "\\`\\\\" this-word))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4950 (eq (following-char) ?\\)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4951 (search-backward "\\" nil t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4952 t))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4953 (if (interactive-p)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4954 ;; 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
4955 (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
4956 (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
4957 ;; 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
4958 (and (looking-at re)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4959 (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
4960 (goto-char (match-end 0)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4961
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4962
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4963 (unless macro
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4964 (error "No cross reference to display"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4965
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4966 ;; 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
4967 (reftex-access-scan-info current-prefix-arg)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4968
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4969 (cond
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4970 ((string= macro "cite")
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4971 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4972 ((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
4973 (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
4974 args (list
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4975 (reftex-this-word "^{},%\n\r")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4976 (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
4977 ((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
4978 (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
4979 args (list
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4980 (reftex-this-word "^{},%\n\r")
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4981 (list (cdr (assq 'thebib
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4982 (symbol-value reftex-docstruct-symbol))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4983 nil t t)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
4984 (t (error "Cannot display crossref\n"))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4985 ((string= macro "ref")
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4986 (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
4987 (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
4988 (xr-re (nth 2 xr-data))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4989 (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
4990
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4991 (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
4992 ;; Label is defined in external document
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4993 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4994 (save-match-data
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4995 (set-buffer
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4996 (or (reftex-get-file-buffer-force
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
4997 (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
4998 (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
4999 (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
5000 (reftex-access-scan-info)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5001 (setq entry
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5002 (assoc label (symbol-value reftex-docstruct-symbol)))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5003 (if entry
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5004 (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
5005 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
5006 (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
5007 (t (error "This should not happen (reftex-view-crossref)")))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5008 (setq point (point))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5009 (apply cmd args)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5010 (setq pop-window (selected-window))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5011 (add-hook 'pre-command-hook 'reftex-highlight-shall-die)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5012 (select-window my-window)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5013 (goto-char point)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5014 (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
5015 (select-window pop-window))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5016
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5017 (defun reftex-mouse-view-crossref (ev)
18123
7831ac89a334 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18050
diff changeset
5018 "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
5019 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
5020 If it is a \\cite, show the BibTeX database entry.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5021 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
5022 With argument, actually select the window showing the cross reference."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5023 (interactive "e")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5024 (mouse-set-point ev)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5025 (reftex-view-crossref current-prefix-arg))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5026
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5027 ;;; ===========================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5028 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5029 ;;; Functions that check out the surroundings
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5030
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5031 (defun reftex-what-macro (which &optional bound)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5032 ;; 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
5033 ;; 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
5034
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5035 ;; If WHICH is nil, immediately return nil.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5036 ;; If WHICH is t, return list of all macros enclosing point.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5037 ;; 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
5038 ;; name of the first macro in this list found to enclose point.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5039 ;; 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
5040 ;; 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
5041 ;; like statement.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5042
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5043 ;; 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
5044 ;; 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
5045 ;; 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
5046 ;; considered an argument of macro \macro.
18050
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 (catch 'exit
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5049 (if (null which) (throw 'exit nil))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5050 (let ((bound (or bound (save-excursion (re-search-backward
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5051 reftex-section-regexp nil 1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5052 (point))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5053 pos cmd-list cmd cnt cnt-opt entry)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5054 (save-restriction
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5055 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5056 (narrow-to-region (max 1 bound) (point-max))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5057 ;; move back out of the current parenthesis
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5058 (while (condition-case nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5059 (progn (up-list -1) t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5060 (error nil))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5061 (setq cnt 1 cnt-opt 0)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5062 ;; 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
5063 (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
5064 (condition-case nil
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5065 (progn (backward-sexp) t)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5066 (error nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5067 (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
5068 (incf cnt))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5069 (setq pos (point))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5070 (when (and (or (= (following-char) ?\[)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5071 (= (following-char) ?\{))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5072 (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
5073 (setq cmd (reftex-match-string 0))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5074 (when (looking-at "\\\\begin{[^}]*}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5075 (setq cmd (reftex-match-string 0)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5076 cnt (1- cnt)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5077 ;; 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
5078 (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
5079 (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
5080 (setq cmd nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5081 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5082 ((null cmd))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5083 ((eq t which)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5084 (push (cons cmd (point)) cmd-list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5085 ((member cmd which)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5086 (throw 'exit (cons cmd (point))))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5087 (goto-char pos)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5088 (nreverse cmd-list)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5089
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5090 (defun reftex-what-environment (which &optional bound)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5091 ;; 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
5092 ;; 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
5093 ;; them.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5094
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5095 ;; If WHICH is nil, immediately return nil.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5096 ;; If WHICH is t, return list of all environments enclosing point.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5097 ;; 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
5098 ;; 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
5099 ;; point.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5100
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5101 ;; 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
5102 ;; 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
5103
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5104 (catch 'exit
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5105 (save-excursion
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5106 (if (null which) (throw 'exit nil))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5107 (let ((bound (or bound (save-excursion (re-search-backward
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5108 reftex-section-regexp nil 1)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5109 (point))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5110 env-list end-list env)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5111 (while (re-search-backward "\\\\\\(begin\\|end\\){\\([^}]+\\)}"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5112 bound t)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5113 (setq env (buffer-substring-no-properties
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5114 (match-beginning 2) (match-end 2)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5115 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5116 ((string= (match-string 1) "end")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5117 (add-to-list 'end-list env))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5118 ((member env end-list)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5119 (setq end-list (delete env end-list)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5120 ((eq t which)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5121 (push (cons env (point)) env-list))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5122 ((member env which)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5123 (throw 'exit (cons env (point))))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5124 (nreverse env-list)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5125
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5126 ;; ============================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5127 ;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5128 ;; Some generally useful functions
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5129
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5130 (defun reftex-no-props (string)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5131 ;; Return STRING with all text properties removed
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5132 (and (stringp string)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5133 (set-text-properties 0 (length string) nil string))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5134 string)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5135
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5136 (defun reftex-match-string (n)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5137 ;; Match string without properties
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5138 (when (match-beginning n)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5139 (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
5140
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5141 (defun reftex-kill-buffer (buffer)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5142 ;; 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
5143 (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
5144 (kill-buffer buffer)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5145
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5146 (defun reftex-erase-buffer (&optional buffer)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5147 ;; 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
5148 ;; This even erases read-only buffers.
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5149 (cond
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5150 ((null buffer)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5151 ;; erase current buffer
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5152 (let ((buffer-read-only nil)) (erase-buffer)))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5153 ((setq buffer (get-buffer buffer))
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5154 ;; buffer exists
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5155 (save-excursion
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5156 (set-buffer buffer)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5157 (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
5158
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5159 (defun reftex-this-word (&optional class)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5160 ;; Grab the word around point.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5161 (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
5162 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5163 (buffer-substring-no-properties
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5164 (progn (skip-chars-backward class) (point))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5165 (progn (skip-chars-forward class) (point)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5166
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5167 (defvar enable-multibyte-characters)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5168 (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
5169 ;; Truncate a string to NCHAR characters.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5170 ;; 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
5171 ;; 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
5172 (setq string
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5173 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5174 ((and (boundp 'enable-multibyte-characters)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5175 enable-multibyte-characters)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5176 (if (<= (string-width string) ncols)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5177 string
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5178 (if ellipses
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5179 (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
5180 (truncate-string-to-width string ncols))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5181 (t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5182 (if (<= (length string) ncols)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5183 string
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5184 (if ellipses
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5185 (concat (substring string 0 (- ncols 3)) "...")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5186 (substring string 0 ncols))))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5187 (if padding
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5188 (format (format "%%-%ds" ncols) string)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5189 string))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5190
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5191 (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
5192 ;; 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
5193 ;; 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
5194 ;; 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
5195 (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
5196 (goto-char start)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5197 (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
5198 (setq match1 (match-data)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5199 (goto-char start)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5200 (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
5201 (setq match2 (match-data)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5202 (goto-char start)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5203 (setq match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5204 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5205 ((not match1) match2)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5206 ((not match2) match1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5207 ((< (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
5208 (t match2)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5209 (if match (progn (store-match-data match) t) nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5210
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5211 (defun reftex-auto-mode-alist ()
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5212 ;; 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
5213 ;; Stolen from gnus nnheader.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5214 (let ((alist auto-mode-alist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5215 out)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5216 (while alist
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5217 (when (listp (cdr (car alist)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5218 (push (car alist) out))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5219 (pop alist))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5220 (nreverse out)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5221
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5222 (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
5223 ;; 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
5224 ;; 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
5225 (let* ((win1 (selected-window))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5226 (buf1 (current-buffer))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5227 (win2 (get-buffer-window buf2)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5228 (when win2
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5229 (select-window win2)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5230 (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
5231 (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
5232 (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
5233 (window-height))))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5234 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5235 ((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
5236 (keep-current
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5237 ;; 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
5238 (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
5239 (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
5240
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5241 (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
5242 ;; 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
5243 ;; 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
5244 ;; FILE is just for the message.
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5245 (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
5246 (status (get pathvar 'status)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5247 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5248 ((eq status 'recursed))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5249 ((and status (null recurse)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5250 ((null status)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5251 (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
5252 reftex-bibpath-environment-variables)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5253 (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
5254 (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
5255 env-vars path-separator))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5256 (put pathvar 'status 'split))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5257 ((and (eq 'split status) recurse)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5258 (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
5259 (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
5260 (put pathvar 'status 'recursed)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5261
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5262 (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
5263 ;; 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
5264 (catch 'exit
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5265 (when (file-name-absolute-p file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5266 (if (file-exists-p file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5267 (throw 'exit file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5268 (throw 'exit nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5269 (let* ((thepath path) file1 dir
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5270 (doubleslash (concat "/" "/")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5271 (while (setq dir (pop thepath))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5272 (when (string= (substring dir -2) doubleslash)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5273 (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
5274 (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
5275 (if (file-exists-p file1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5276 (throw 'exit file1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5277 ;; No such file
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5278 nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5279
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5280 (defun reftex-parse-colon-path (path)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5281 ;; 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
5282 (mapcar 'file-name-as-directory
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5283 (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
5284
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5285 (defun reftex-expand-path (path)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5286 ;; 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
5287 (let (path1 dir dirs (doubleslash (concat "/" "/")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5288 (while (setq dir (pop path))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5289 (if (string= (substring dir -2) doubleslash)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5290 (progn
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5291 (setq dir (substring dir 0 -1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5292 (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
5293 (setq path1 (append dirs path1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5294 (push dir path1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5295 (nreverse path1)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5296
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5297 (defun reftex-recursive-directory-list (dir)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5298 (let ((path (list dir)) dirs path1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5299 (while (setq dir (pop path))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5300 (setq dirs
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5301 (delete nil
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5302 (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5303 (function
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5304 (lambda (x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5305 (if (and (file-directory-p x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5306 (not (string-match "/\\.+\\'" x)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5307 (file-name-as-directory x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5308 nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5309 (directory-files dir t))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5310 (setq path (append dirs path))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5311 (push dir path1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5312 path1))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5313
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5314 (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
5315 ;; 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
5316 (let ((start -2))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5317 (setq string (regexp-quote string))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5318 (while (setq start (string-match "[\n\r]" string (+ 3 start)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5319 (setq string (replace-match "[\n\r]" nil t string)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5320 string))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5321
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5322 (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
5323 ;; 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
5324 ;; 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
5325 (let* ((n (1+ (string-match "[[{]" old)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5326 (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
5327 (old (substring old n)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5328 (while (string-match
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5329 "\\([\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
5330 old)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5331 (if (match-beginning 1)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5332 (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
5333 (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
5334 (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
5335 new))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5336
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5337 (defun reftex-delete-list (elt-list list)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5338 ;; like delete, but with a list of things to delete
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5339 ;; (original code from Rory Molinari)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5340 (while elt-list
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5341 (setq list (delete (car elt-list) list)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5342 elt-list (cdr elt-list)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5343 list)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5344
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5345 (defun reftex-get-buffer-visiting (file)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5346 ;; return a buffer visiting FILE
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5347 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5348 ((boundp 'find-file-compare-truenames) ; XEmacs
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5349 (let ((find-file-compare-truenames t))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5350 (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
5351 ((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
5352 (find-buffer-visiting file))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5353 (t (error "This should not happen (reftex-get-buffer-visiting)"))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5354
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5355 (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
5356 ;; 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
5357 ;; 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
5358 ;; 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
5359 ;; 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
5360 ;; and mark the buffer to be killed after use.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5361
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5362 (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
5363
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5364 (cond (buf
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5365 ;; 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
5366 buf)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5367
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5368 ((file-readable-p file)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5369 ;; 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
5370
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5371 (if (or (not mark-to-kill)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5372 (eq t reftex-initialize-temporary-buffers))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5373
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5374 ;; Visit the file with full magic
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5375 (setq buf (find-file-noselect file))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5376
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5377 ;; 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
5378 ;; with limited Magic
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5379
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5380 ;; The magic goes away
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5381 (let ((format-alist nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5382 (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
5383 (default-major-mode 'fundamental-mode)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5384 (enable-local-variables nil)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5385 (after-insert-file-functions nil))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5386 (setq buf (find-file-noselect file)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5387
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5388 ;; Is there a hook to run?
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5389 (when (listp reftex-initialize-temporary-buffers)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5390 (save-excursion
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5391 (set-buffer buf)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5392 (run-hooks 'reftex-initialize-temporary-buffers))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5393
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5394 ;; 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
5395 (and mark-to-kill
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5396 (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
5397
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5398 ;; Return the new buffer
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5399 buf)
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 ;; 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
5402 (t nil))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5403
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5404 (defun reftex-splice-symbols-into-list (list alist)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5405 ;; 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
5406 ;; Return new list.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5407 (let (rtn tmp)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5408 (while list
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5409 (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
5410 (symbolp (car list)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5411 (setq tmp (car list))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5412 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5413 ((assoc tmp alist)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
5414 (setq list (append (nth 2 (assoc tmp alist)) (cdr list))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5415 (t
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5416 (error "Cannot treat symbol %s in reftex-label-alist"
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5417 (symbol-name tmp)))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5418 (push (pop list) rtn))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5419 (nreverse rtn)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5420
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5421 (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
5422 ;; 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
5423 ;; Elements of KEEP-LIST are not removed even if duplicate.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5424 (let (new elm)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5425 (while alist
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5426 (setq elm (pop alist))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5427 (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
5428 (not (assoc (car elm) new)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5429 (push elm new)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5430 (nreverse new)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5431
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5432 (defun reftex-use-fonts ()
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
5433 ;; Return t if we can and want to use fonts.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5434 (and window-system
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5435 reftex-use-fonts
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5436 (featurep 'font-lock)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5437
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5438 (defun reftex-refontify ()
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5439 ;; 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
5440 (and (reftex-use-fonts)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5441 (or (eq t reftex-refontify-context)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5442 (and (eq 1 reftex-refontify-context)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5443 (or (featurep 'x-symbol))))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5444
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5445 (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
5446 ;; Fontify the `*RefTeX Select*' buffer
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5447 (cond
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5448 ((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
5449 ;; 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
5450 (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
5451 '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
5452 (let ((major-mode 'latex-mode))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5453 (font-lock-mode 1)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5454 ((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
5455 ;; Looks like the XEmacs font-lock stuff.
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5456 ;; FIXME: this is still kind of a hack, but might go away with XEmacs 20.4
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5457 (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
5458 (let ((major-mode 'latex-mode)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5459 (font-lock-defaults-computed nil))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5460 (font-lock-set-defaults-1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5461 (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
5462 (t
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5463 ;; Oops?
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5464 (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
5465
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5466 (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
5467 ;; 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
5468 (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
5469 '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 'font-lock-fontify-region))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5471 beg1 end1)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5472 (goto-char beg)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5473 (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
5474 (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
5475 (funcall func beg1 end1 nil)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5476 (goto-char end1))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5477
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
5478 ;; 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
5479 ;; the overlay library, available in version 19.15
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5480 (and (not (fboundp 'make-overlay))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5481 (condition-case nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5482 (require 'overlay)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5483 (error
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5484 (error "RefTeX needs overlay emulation (available in XEmacs 19.15)"))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5485
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5486 ;; 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
5487 (defvar reftex-highlight-overlays [nil nil])
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5488
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5489 ;; Initialize the overlays
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5490 (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
5491 (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
5492 'face 'highlight)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5493 (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
5494 (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
5495 'face reftex-cursor-selected-face)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5496
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5497 ;; Two functions for activating and deactivation highlight overlays
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5498 (defun reftex-highlight (index begin end &optional buffer)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5499 "Highlight a region with overlay INDEX."
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5500 (move-overlay (aref reftex-highlight-overlays index)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5501 begin end (or buffer (current-buffer))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5502 (defun reftex-unhighlight (index)
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5503 "Detach overlay INDEX."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5504 (delete-overlay (aref reftex-highlight-overlays index)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5505
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5506 (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
5507 ;; Function used in pre-command-hook to remove highlights.
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5508 (remove-hook 'pre-command-hook 'reftex-highlight-shall-die)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5509 (reftex-unhighlight 0))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5510
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5511 ;;; ---------------------------------------------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5512 ;;;
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5513 ;;; Functions to compile the tables, reset the mode etc.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5514
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5515 (defun reftex-reset-mode ()
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
5516 "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
5517 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
5518 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
5519 these variables."
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5520 (interactive)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5521
18219
aaeaae005e98 Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents: 18123
diff changeset
5522 ;; Record that we have done this
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5523 (setq reftex-tables-dirty nil)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5524 (setq reftex-memory
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5525 (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
5526 reftex-default-label-alist-entries))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5527
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5528 ;; Reset the file search path variables
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5529 (put 'reftex-tex-path 'status nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5530 (put 'reftex-bib-path 'status nil)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5531
18219
aaeaae005e98 Updated documentation at several points in the file.
Richard M. Stallman <rms@gnu.org>
parents: 18123
diff changeset
5532 ;; 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
5533 ;; 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
5534 (save-excursion
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5535 (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
5536 "*Duplicate Labels*" "*toc*" "*RefTeX-scratch*"))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5537 buf)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5538 (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
5539 (if (get-buffer buf)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5540 (kill-buffer buf))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5541 (reftex-erase-all-selection-buffers))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5542
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5543 ;; 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
5544 (reftex-reset-scanning-information)
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
5545
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5546 ;; 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
5547 (reftex-plug-into-AUCTeX)
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
5548
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5549 (message "updating internal tables...")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5550 (reftex-compute-ref-cite-tables)
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
5551 (message "updating internal tables... done"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5552
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5553 (defun reftex-reset-scanning-information ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5554 "Reset the symbols containing information from buffer scanning.
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5555 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
5556 (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
5557 (reftex-erase-buffer "*toc*"))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5558 (let ((symlist reftex-multifile-symbols)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5559 symbol)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5560 (while symlist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5561 (setq symbol (car symlist)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5562 symlist (cdr symlist))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5563 (if (and (symbolp (symbol-value symbol))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5564 (not (null (symbol-value symbol))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5565 (set (symbol-value symbol) nil)))))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5566
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5567 (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
5568 ;; 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
5569 (mapcar (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5570 (lambda (type)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5571 (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
5572 reftex-typekey-list))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5573
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5574 (defun reftex-compute-ref-cite-tables ()
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5575 ;; Update ref and cite tables
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5576
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5577 ;; Update AUCTeX style information
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5578 (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
5579 (condition-case nil (TeX-update-style) (error nil)))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5580
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5581 ;; Compile information in reftex-label-alist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5582 (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
5583 (append
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5584 reftex-label-alist
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5585 reftex-label-alist-external-add-ons
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5586 reftex-default-label-alist-entries)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5587 reftex-label-alist-builtin)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5588 '(nil)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5589 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
5590 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
5591 nargs nlabel opt-args cell sum i words-are-re)
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5592
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5593 (setq reftex-words-to-typekey-alist nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5594 reftex-typekey-list nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5595 reftex-typekey-to-format-alist nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5596 reftex-typekey-to-prefix-alist nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5597 reftex-env-or-mac-alist nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5598 reftex-label-env-list nil
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5599 reftex-label-mac-list nil)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5600 (while tmp
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5601 (catch 'next-entry
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5602 (setq entry (car tmp)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5603 env-or-mac (car entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5604 entry (cdr entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5605 tmp (cdr tmp))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5606 (if (null env-or-mac)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5607 (setq env-or-mac ""))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5608 (if (stringp (car entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5609 ;; 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
5610 ;; 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
5611 (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
5612 (cons (concat (car entry) ":")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5613 (cdr entry)))))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5614 (setq typekeychar (nth 0 entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5615 typekey (char-to-string typekeychar)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5616 prefix (nth 1 entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5617 fmt (nth 2 entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5618 context (nth 3 entry)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5619 wordlist (nth 4 entry))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5620 (if (stringp wordlist)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5621 ;; 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
5622 (setq wordlist (nthcdr 4 entry)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5623
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5624 (if (and (stringp fmt)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5625 (string-match "@" fmt))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5626 ;; 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
5627 (setq fmt (split-string fmt "@+"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5628 (setq fmt (list "\\label{%s}" fmt)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5629 (setq labelfmt (car fmt)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5630 reffmt (nth 1 fmt))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5631 (if typekey
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5632 (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
5633 (if (and typekey prefix
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5634 (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
5635 (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
5636 (cons typekey prefix)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5637 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5638 ((string-match "\\`\\\\" env-or-mac)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5639 ;; It's a macro
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5640 (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
5641 (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
5642 nargs (second result)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5643 nlabel (third result)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5644 opt-args (fourth result))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5645 (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
5646 (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
5647 (t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5648 (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
5649 (cond ((string= env-or-mac "any"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5650 ((string= env-or-mac ""))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5651 ((string= env-or-mac "section"))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5652 (t
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5653 (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
5654 ;; Translate some special context cases
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5655 (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
5656 (setq context
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5657 (format
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5658 (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
5659 (regexp-quote env-or-mac))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5660 (and reffmt
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5661 (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
5662 (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
5663 (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
5664 (not (string= env-or-mac ""))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5665 (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
5666 (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
5667 nargs nlabel opt-args)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5668 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
5669 (if (eq (car wordlist) 'regexp)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5670 (setq wordlist (cdr wordlist)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5671 words-are-re t)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5672 (setq words-are-re nil))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5673 (while (and (setq word (pop wordlist))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5674 (stringp word))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5675 (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
5676 (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
5677 (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
5678 (cond
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5679 ((string= "" env-or-mac) nil)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5680 ((setq cell (assoc typekey qh-list))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5681 (push env-or-mac (cdr cell)))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5682 (t
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5683 (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
5684
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5685 (setq qh-list
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5686 (sort qh-list (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5687 (lambda (x1 x2) (string< (car x1) (car x2))))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5688 (setq reftex-typekey-to-prefix-alist
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5689 (nreverse reftex-typekey-to-prefix-alist))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5690 (setq reftex-type-query-prompt
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5691 (concat "Label type: "
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5692 (mapconcat (function (lambda(x) (format "[%s]" (car x))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5693 qh-list " ")
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5694 " (?=Help)"))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5695 (setq reftex-type-query-help
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5696 (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
5697 (mapconcat
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5698 (function
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5699 (lambda(x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5700 (setq sum 0)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5701 (format " [%s] %s"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5702 (car x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5703 (mapconcat
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5704 (lambda(x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5705 (setq sum (+ sum (length x)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5706 (if (< sum 60)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5707 x
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5708 (setq sum 0)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5709 (concat "\n " x)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5710 (cdr x) " "))))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5711 qh-list "\n")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5712
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5713 ;; 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
5714 (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
5715 (mapcar
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5716 (lambda (x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5717 (setq word (car x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5718 typekey (cdr x)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5719 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
5720 (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
5721 (setq i 0)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5722 (while (and (< i 10)
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5723 (< i (length fmt))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5724 (not (member (aref fmt i) '(?%))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5725 (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
5726 (substring fmt 0 (1+ i)))))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5727 (incf i))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5728 (cons (concat word "\\)\\=") typekey))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5729 (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
5730
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5731 ;; Calculate the regular expressions
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5732 (let ((label-re "\\\\label{\\([^}]*\\)}")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5733 (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
5734 (section-re
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5735 (concat "\\(\\`\\|[\n\r]\\)[ \t]*\\\\\\("
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5736 (mapconcat 'car reftex-section-levels "\\|")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5737 "\\)\\*?\\(\\[[^]]*\\]\\)?{"))
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5738 (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
5739 (macro-re
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5740 (if macros-with-labels
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5741 (concat "\\("
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5742 (mapconcat 'regexp-quote macros-with-labels "\\|")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5743 "\\)[[{]")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5744 ""))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5745 (find-label-re-format
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5746 (concat "\\("
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5747 (mapconcat 'regexp-quote (append '("\\label")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5748 macros-with-labels) "\\|")
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5749 "\\)\\([[{][^]}]*[]}]\\)*[[{]\\(%s\\)[]}]")))
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5750 (setq reftex-section-regexp section-re
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5751 reftex-section-or-include-regexp
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5752 (concat section-re "\\|" include-re)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5753 reftex-everything-regexp
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5754 (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
5755 "\\|" appendix-re
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5756 (if macros-with-labels "\\|" "") macro-re)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5757 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
5758 reftex-find-label-regexp-format2
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5759 "\\([]} \t\n\r]\\)\\([[{]\\)\\(%s\\)[]}]"))))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5760
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5761 ;;; Keybindings --------------------------------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5762
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5763 (define-key reftex-mode-map "\C-c=" 'reftex-toc)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5764 (define-key reftex-mode-map "\C-c(" 'reftex-label)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5765 (define-key reftex-mode-map "\C-c)" 'reftex-reference)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5766 (define-key reftex-mode-map "\C-c[" 'reftex-citation)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5767 (define-key reftex-mode-map "\C-c&" 'reftex-view-crossref)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5768
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5769 ;; If the user requests so, she can have a few more bindings:
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5770 (cond
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5771 (reftex-extra-bindings
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5772 (define-key reftex-mode-map "\C-ct" 'reftex-toc)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5773 (define-key reftex-mode-map "\C-cl" 'reftex-label)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5774 (define-key reftex-mode-map "\C-cr" 'reftex-reference)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5775 (define-key reftex-mode-map "\C-cc" 'reftex-citation)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5776 (define-key reftex-mode-map "\C-cv" 'reftex-view-crossref)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5777 (define-key reftex-mode-map "\C-cg" 'reftex-grep-document)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5778 (define-key reftex-mode-map "\C-cs" 'reftex-search-document)))
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5779
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5780 ;; Selection Keymaps
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5781 (let ((map (make-sparse-keymap)))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5782 ; First, the common stuff
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5783 (substitute-key-definition
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5784 '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
5785 (substitute-key-definition
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5786 '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
5787 (substitute-key-definition
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5788 '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
5789 (substitute-key-definition
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5790 '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
5791 (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
5792 (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
5793 (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
5794 (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
5795 (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
5796 (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
5797 (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
5798 (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
5799 (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
5800 (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
5801 (define-key map "?" 'reftex-select-help)
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5802 (if (string-match "XEmacs" emacs-version)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5803 (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
5804 (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
5805
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5806 (loop for key across "0123456789" do
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5807 (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
5808 (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
5809
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5810 (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
5811 (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
5812
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5813 ;; Now the rest
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5814
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5815 (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
5816 (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
5817 (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
5818 (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
5819 (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
5820 (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
5821 (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
5822 (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
5823 (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
5824
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5825 (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
5826 (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
5827 (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
5828 (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
5829 (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
5830
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5831 ;; Table of Contents map
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5832 (let ((map reftex-toc-map))
20979
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5833 (if (string-match "XEmacs" emacs-version)
38e7bcbb3595 (reftex-toc-mode, reftex-select-label-mode):
Karl Heuer <kwzh@gnu.org>
parents: 20953
diff changeset
5834 (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
5835 (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
5836 (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
5837 (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
5838 (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
5839 (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
5840 (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
5841 (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
5842 (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
5843 (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
5844 (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
5845 (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
5846 (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
5847 (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
5848 (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
5849 (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
5850 (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
5851 (define-key map "-" 'negative-argument))
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5852
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5853 ;;; Menus --------------------------------------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5854
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5855 ;; 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
5856
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5857 (require 'easymenu)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5858
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5859 (easy-menu-define
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5860 reftex-mode-menu reftex-mode-map
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5861 "Menu used in RefTeX mode"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5862 `("Ref"
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
5863 ["Table of Contents" reftex-toc t]
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5864 "----"
19660
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
5865 ["\\label" reftex-label t]
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
5866 ["\\ref" reftex-reference t]
fa3d4e7a76d9 (reftex-customize): Added call to customize browse.
Richard M. Stallman <rms@gnu.org>
parents: 18321
diff changeset
5867 ["\\cite" reftex-citation t]
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5868 ["View Crossref" reftex-view-crossref t]
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5869 "----"
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5870 ("Parse Document"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5871 ["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
5872 ["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
5873 ["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
5874 (> (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
5875 ["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
5876 "----"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5877 ["Enable Partial Scans"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5878 (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
5879 :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
5880 ["Auto-Save Parse Info"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5881 (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
5882 :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
5883 "---"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5884 ["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
5885 ("Global Actions"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5886 ["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
5887 ["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
5888 ["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
5889 "----"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5890 ["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
5891 "----"
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5892 ["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
5893 ["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
5894 ;;;["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
5895 "---"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5896 ["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
5897 "---"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5898 ("Reference Options"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5899 "Varioref Setting"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5900 ["Use `\\vref' by Default"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5901 (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
5902 :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
5903 "---"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5904 "Selection Buffers"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5905 ["Use Multiple Buffers"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5906 (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
5907 (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
5908 :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
5909 ["Auto Update Buffers"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5910 (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
5911 (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
5912 :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
5913 ("Citation Options"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5914 "Citation Style"
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5915 ,@(mapcar
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5916 (function
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5917 (lambda (x)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5918 (vector
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5919 (capitalize (symbol-name (car x)))
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5920 (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
5921 ':style 'radio ':selected
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5922 (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
5923 reftex-cite-format-builtin)
20102
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5924 "----"
20177
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5925 "Bibinfo in Comments"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5926 ["Attach Comments"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5927 (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
5928 :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
5929 "---"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5930 "Sort Database Matches"
6ebc3e300106 The menu now used toggle and radio for some items.
Karl Heuer <kwzh@gnu.org>
parents: 20102
diff changeset
5931 ["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
5932 :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
5933 ["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
5934 :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
5935 ["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
5936 :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
5937 ["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
5938 :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
5939 ("Customize"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5940 ["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
5941 "---"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5942 ["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
5943 (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
5944 "----"
20829
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5945 ("Documentation"
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5946 ["Info" reftex-info t]
f9ac469887a8 (reftex-toc): Fixed bug with split-window. Using
Richard M. Stallman <rms@gnu.org>
parents: 20177
diff changeset
5947 ["Commentary" reftex-show-commentary t])))
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5948
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5949 ;;; Run Hook ------------------------------------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5950
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5951 (run-hooks 'reftex-load-hook)
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5952
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5953 ;;; That's it! ----------------------------------------------------------------
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5954
21114
3e8ab19bdccb 1998-03-08 Carsten Dominik <cd@gnu.org>
Carsten Dominik <dominik@science.uva.nl>
parents: 21075
diff changeset
5955 (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
5956 (provide 'reftex)
c00f010468c2 Using cl macros push, pop, when, unless throughout
Karl Heuer <kwzh@gnu.org>
parents: 19660
diff changeset
5957
18050
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5958 ;;;============================================================================
506b35a4537e Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5959
18321
0ed97be54a28 Changed all doc strings to comply with conventions.
Richard M. Stallman <rms@gnu.org>
parents: 18220
diff changeset
5960 ;;; reftex.el ends here